addOnUISdk.app.oauth
Provides access to the OAuth API methods needed for implementing the user authorization with OAuth 2.0 use case. Be sure to check out the code samples as well for more extensive examples of using this workflow.
Methods
authorize()
Authorize a user using OAuth 2.0 PKCE workflow.
Signature
authorize(request: AuthorizationRequest): Promise<AuthorizationResponse>
Parameters
requestobjectAuthorizationRequest object payload with parameters to be used in the authorization workflow.AuthorizationRequest
authorizationUrlstringclientIdstringscopestringcodeChallengestringadditionalParameters?Map<string, string>windowSize?{ width: number; height: number }object containing the desired width and height as a number. <br/><br/>NOTE: The minimum (and default) values for windowSize are 480 x 480. The maximum allowed values are 800 x (screen height).Return Value
A resolved Promise with the AuthorizationResponse object containing a one-time authorization code which can be used to obtain an access token.
AuthorizationResponse
idstringcodestringredirectUristringresultstring or objectAuthorizationResult payload which denotes either success or failure. In the event of a "FAILED" status reported by the OAuth provider during authorization, the value of this property is an object, in the form of {[failure_title]: "failure_description"}, and for all other statuses the value of description is a string.authorizeWithOwnRedirect()
Initiate the OAuth 2.0 PKCE authorization workflow by opening the user sign-in window. After authorization, the user is redirected to the add-on developer provided URL.
Signature:
authorizeWithOwnRedirect(request: AuthorizeWithOwnRedirectRequest): Promise<AuthorizationResult>
Parameters
requestobjectAuthorizeWithOwnRedirectRequest object payload with parameters to be used in the authorization workflow.AuthorizeWithOwnRedirectRequest
authorizationUrlstringclientIdstringscopestringcodeChallengestringadditionalParameters?Map<string, string>windowSize?{ width: number; height: number }object containing the desired width and height as a number. <br/><br/>NOTE: The minimum (and default) values for windowSize are 480 x 480. The maximum allowed values are 800 x (screen height).redirectUristringstatestringredirectUri. Although the primary reason for using the state parameter is to mitigate CSRF attacks, it can also be used to encode any other information.Return Value
A resolved Promise with the AuthorizationResult object, which contains a status and a description, which will either be a string or an object. In the event of a FAILED status reported by the OAuth provider during authorization, the value of this property is an object, in the form of {[failure_title]: "failure_description"}, and for all other statuses, the value of description is a string.
AuthorizationResult
statusAuthorizationStatusdescriptionstring or objectobject, in the form of {[failure_title]: "failure_description"}. While for all other statuses the value of this property is a stringAuthorizationStatus
Each of the statuses returned below is the exact name as a string (ie: SUCCESS = "SUCCESS")
stringstringstringstringErrors
The table below describes the possible error statuses returned when using the OAuth API, with a description of the scenario that will return them.
<br/>