Creates a new OAuth2 service.
Parameters: Name Type DescriptionserviceName
string The name of the service.
Obtain an access token using the custom grant type specified. Most often this will be "client_credentials", and a client ID and secret are set an "Authorization: Basic ..." header will be added using those values.
Fetches a new token from the OAuth server.
Parameters: Name Type Attributes Descriptionpayload
Object The token request payload. optUrl
string <optional>
The parsed token.
Gets an access token for this service. This token can be used in HTTP requests to the service's endpoint. This method will throw an error if the user's access was not granted or has expired.
An access token.
Gets the authorization URL. The first step in getting an OAuth2 token is to have the user visit this URL and approve the authorization request. The user will then be redirected back to your application using callback function name specified, so that the flow may continue.
Parameters: Name Type DescriptionoptAdditionalParameters
Object Additional parameters that should be stored in the state token and made available in the callback function.
The authorization URL.
Gets an id token for this service. This token can be used in HTTP requests to the service's endpoint. This method will throw an error if the user's access was not granted or has expired.
An id token.
Gets the last error that occurred this execution when trying to automatically refresh or generate an access token.
An error, if any.
Returns the redirect URI that will be used for this service. Often this URI needs to be entered into a configuration screen of your OAuth provider.
The redirect URI.
Gets the storage layer for this service, used to persist tokens. Custom values associated with the service can be stored here as well. The key null
is used to to store the token and should not be used.
The service's storage.
Gets the token from the service's property store or cache.
Parameters: Name Type Attributes DescriptionoptSkipMemoryCheck
boolean <nullable>
The token, or null if no token was found.
Completes the OAuth2 flow using the request data passed in to the callback function.
Parameters: Name Type DescriptioncallbackRequest
Object The request data recieved from the callback function.
True if authorization was granted, false if it was denied.
Determines if the service has access (has been authorized and hasn't expired). If offline access was granted and the previous token has expired this method attempts to generate a new token.
true if the user has access to the service, false otherwise.
Refreshes a token that has expired. This is only possible if offline access was requested when the token was authorized.
Resets the service, removing access and requiring the service to be re-authorized. Also removes any additional values stored in the service's storage.
Sets additional JWT claims to use for Service Account authorization.
Parameters: Name Type DescriptionadditionalClaims
Object.<string, string> The additional claims, as key-value pairs.
This service, for chaining.
Sets the service's authorization base URL (required). For Google services this URL should be https://accounts.google.com/o/oauth2/auth.
Parameters: Name Type DescriptionauthorizationBaseUrl
string The authorization endpoint base URL.
This service, for chaining.
Sets the cache to use when persisting credentials (optional). Using a cache will reduce the need to read from the property store and may increase performance. In most cases this should be a private cache, but a public cache may be appropriate if you want to share access across users.
Parameters: Name Type Descriptioncache
CacheService.Cache The cache to use when persisting credentials.
Returns:
This service, for chaining.
Sets the name of the authorization callback function (required). This is the function that will be called when the user completes the authorization flow on the service provider's website. The callback accepts a request parameter, which should be passed to this service's handleCallback()
method to complete the process.
callbackFunctionName
string The name of the callback function.
This service, for chaining.
Sets the client ID to use for the OAuth flow (required). You can create client IDs in the "Credentials" section of a Google Developers Console project. Although you can use any project with this library, it may be convinient to use the project that was created for your script. These projects are not visible if you visit the console directly, but you can access it by click on the menu item "Resources > Advanced Google services" in the Script Editor, and then click on the link "Google Developers Console" in the resulting dialog.
Parameters: Name Type DescriptionclientId
string The client ID to use for the OAuth flow.
This service, for chaining.
Sets the client secret to use for the OAuth flow (required). See the documentation for setClientId()
for more information on how to create client IDs and secrets.
clientSecret
string The client secret to use for the OAuth flow.
This service, for chaining.
Sets number of minutes that a token obtained through Service Account authorization should be valid. Default: 60 minutes.
Parameters: Name Type DescriptionexpirationMinutes
string The expiration duration in minutes.
This service, for chaining.
Sets the OAuth2 grant_type to use when obtaining an access token. This does not need to be set when using either the authorization code flow (AKA 3-legged OAuth) or the service account flow. The most common usage is to set it to "client_credentials" and then also set the token headers to include the Authorization header required by the OAuth2 provider.
Parameters: Name Type DescriptiongrantType
string The OAuth2 grant_type value.
This service, for chaining.
Sets the issuer (iss) value to use for Service Account authorization. If not set the client ID will be used instead.
Parameters: Name Type Descriptionissuer
string This issuer value
This service, for chaining.
Sets the lock to use when checking and refreshing credentials (optional). Using a lock will ensure that only one execution will be able to access the stored credentials at a time. This can prevent race conditions that arise when two executions attempt to refresh an expired token.
Parameters: Name Type Descriptionlock
LockService.Lock The lock to use when accessing credentials.
Returns:
This service, for chaining.
Sets an additional parameter to use when constructing the authorization URL (optional). See the documentation for your service provider for information on what parameter values they support.
Parameters: Name Type Descriptionname
string The parameter name. value
string The parameter value.
This service, for chaining.
Sets the private key to use for Service Account authorization.
Parameters: Name Type DescriptionprivateKey
string The private key.
This service, for chaining.
Sets the property store to use when persisting credentials (required). In most cases this should be user properties, but document or script properties may be appropriate if you want to share access across users.
Parameters: Name Type DescriptionpropertyStore
PropertiesService.Properties The property store to use when persisting credentials.
Returns:
This service, for chaining.
Sets the URI to redirect to when the OAuth flow has completed. By default the library will provide this value automatically, but in some rare cases you may need to override it.
Parameters: Name Type DescriptionredirectUri
string The redirect URI.
This service, for chaining.
Sets the service's refresh URL. Some OAuth providers require a different URL to be used when generating access tokens from a refresh token.
Parameters: Name Type DescriptionrefreshUrl
string The refresh endpoint URL.
This service, for chaining.
Sets the scope or scopes to request during the authorization flow (optional). If the scope value is an array it will be joined using the separator before being sent to the server, which is is a space character by default.
Parameters: Name Type Attributes Descriptionscope
string | Array.<string> The scope or scopes to request. optSeparator
string <optional>
This service, for chaining.
Sets the subject (sub) value to use for Service Account authorization.
Parameters: Name Type Descriptionsubject
string This subject value
This service, for chaining.
Sets the format of the returned token. Default: OAuth2.TOKEN_FORMAT.JSON.
Parameters: Name Type DescriptiontokenFormat
OAuth2.TOKEN_FORMAT The format of the returned token.
This service, for chaining.
Sets the additional HTTP headers that should be sent when retrieving or refreshing the access token.
Parameters: Name Type DescriptiontokenHeaders
Object.<string, string> A map of header names to values.
This service, for chaining.
Sets the HTTP method to use when retrieving or refreshing the access token. Default: "post".
Parameters: Name Type DescriptiontokenMethod
string The HTTP method to use.
This service, for chaining.
Sets an additional function to invoke on the payload of the access token request.
Parameters: Name Type DescriptiontokenHandler
tokenHandler tokenHandler A function to invoke on the payload of the request for an access token.
This service, for chaining.
Sets the service's token URL (required). For Google services this URL should be https://accounts.google.com/o/oauth2/token.
Parameters: Name Type DescriptiontokenUrl
string The token endpoint URL.
This service, for chaining.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4