Members
TOKEN_FORMAT :string
The supported formats for the returned OAuth2 token.
Type:
- string
Properties:
Name | Type | Description |
---|---|---|
JSON |
string | JSON format, for example {"access_token": "..."} |
FORM_URL_ENCODED |
string | Form URL-encoded, for example access_token=... |
Methods
createService(serviceName) → {Service_}
Creates a new OAuth2 service with the name specified. It's usually best to
create and configure your service once at the start of your script, and then
reference them during the different phases of the authorization flow.
Parameters:
Name | Type | Description |
---|---|---|
serviceName |
string | The name of the service. |
Returns:
The service object.
- Type
- Service_
decodeJwt_(jwt) → {Object}
Decodes and returns the parts of the JWT. The signature is not verified.
Parameters:
Name | Type | Description |
---|---|---|
jwt |
string | The JWT to decode. |
Returns:
The decoded payload.
- Type
- Object
encodeJwt_(payload, key) → {string}
Encodes and signs a JWT.
Parameters:
Name | Type | Description |
---|---|---|
payload |
Object | The JWT payload. |
key |
string | The key to use when generating the signature. |
Returns:
The encoded and signed JWT.
- Type
- string
extend_(destination, source) → {Object}
Copy all of the properties in the source objects over to the
destination object, and return the destination object.
Parameters:
Name | Type | Description |
---|---|---|
destination |
Object | The combined object. |
source |
Object | The object who's properties are copied to the destination. |
Returns:
A combined object with the desination and source
properties.
- Type
- Object
getRedirectUri(optScriptIdopt) → {string}
Returns the redirect URI that will be used for a given script. Often this URI
needs to be entered into a configuration screen of your OAuth provider.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
optScriptId |
string |
<optional> |
The script ID of your script, which can be found in the Script Editor UI under "File > Project properties". Defaults to the script ID of the script being executed. |
Returns:
The redirect URI.
- Type
- string
getServiceNames(propertyStore) → {Array.<string>}
Gets the list of services with tokens stored in the given property store.
This is useful if you connect to the same API with multiple accounts and
need to keep track of them. If no stored tokens are found this will return
an empty array.
Parameters:
Name | Type | Description |
---|---|---|
propertyStore |
PropertiesService.Properties | The properties to check. |
Returns:
The service names.
- Type
- Array.<string>
toLowerCaseKeys_(obj) → {Object}
Gets a copy of an object with all the keys converted to lower-case strings.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | The object to copy. |
Returns:
A shallow copy of the object with all lower-case keys.
- Type
- Object
Type Definitions
tokenHandler(tokenPayload) → {Object}
Parameters:
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tokenPayload |
Object | A hash of parameters to be sent to the token
URL.
Properties
|
Returns:
A modified hash of parameters to be sent to the token URL.
- Type
- Object