This describes how to set up new (or examine existing) services using the Goa library as described in Oauth2 for Apps Script in a few lines of code (which you should read first for background).

What is a service ?

A service is a OAuth2 process and properties definition. Many OAuth2 providers have slightly different implementations of OAuth2, and of course have different endpoints. Goa provides the concept of ‘a named service’, where it already knows how to deal with particular providers, and which can be specified in your package by name, without the need  to research the details of a specific implementation.
webapp is available to see which services have so far been implemented for Goa. By default it will show all services and their details, but also takes these parameters.
summary=1 – provide a summary of service names
service=servicename – provide details for ‘servicename’
An example of a service definition is given below
To see currently supported services, try the webapp . You can also detect all the services from a script by accessing the cGoa.Service.package object.

Custom services

If you have an OAuth2 provider that Goa doesn’t know about, you can simply add it to the cGoa.Service.package along with its properties in the script you need to use it in. If you do create a custom service, then post it on our community and I’ll add it to the library so others can use it too.

New definitions can be added like this, and should be the first thing you do before creating the Goa.
and used in credentials package like this.

Service definition properties.

These are the available properties to define a service.

 property  purpose  
 authUrl The end point from which to get the authentication code
 tokenUrl The end point at which to exchange the authentication code for an access token
 refreshUrl The end point at which to exchange a refresh token for an access token. For many services this is the same as the tokenUrl
 accountType  Optional. By default the account type is a regular Oauth web client flow. Aside from the default, the only supported value at the time of writing is ‘serviceaccount’, which identities that the service shoudl follow the service account flow.
 accept  Optional. Some services need an accept value in the header. For example, Git hub needs accept: “application/json” to be specified here. Generally speaking this is not required.
 basic  Optional. Some services (for example reddit) need the client id and secret to be encoded
 duration  Optional Some services allow the lifetime of the access token to be specified. For example, Reddit needs this field to be ‘permanent’ before it will issue a refresh token.
 defaultDuration  Optional. The default lifetime in seconds of service account tokens.
Why not join our forum, follow the blog or follow me on Twitter to ensure you get updates when they are available.