Interface: OAuth2Authentication¶
Defined in: types.ts:563
Authenticate using the OAuth2 Authorization Code flow. You must specify the authorization URL, token exchange URL, and scopes here as part of the pack definition. You'll provide the application's client ID and client secret in the pack management UI, so that these can be stored securely.
The API must use a (largely) standards-compliant implementation of OAuth2.
Example¶
pack.setUserAuthentication({
type: coda.AuthenticationType.OAuth2,
// These URLs come from the API's developer documentation.
authorizationUrl: "https://example.com/authorize",
tokenUrl: "https://api.example.com/token",
});
See¶
Extends¶
BaseOAuthAuthentication
Properties¶
additionalParams?¶
optionaladditionalParams:object
Defined in: types.ts:578
Option custom URL parameters and values that should be included when redirecting the user to the authorizationUrl.
Index Signature¶
[key: string]: any
authorizationUrl¶
authorizationUrl:
string
Defined in: types.ts:572
The URL to which the user will be redirected in order to authorize this pack.
This is typically just a base url with no parameters. Coda will append the scope
parameter automatically. If the authorization flow requires additional parameters,
they may be specified using additionalParams.
credentialsLocation?¶
optionalcredentialsLocation:TokenExchangeCredentialsLocation
Defined in: types.ts:525
When making the token exchange request, where to pass the client credentials (client ID and client secret). The default is TokenExchangeCredentialsLocation#Automatic, which should work for most providers. Pick a more specific option if the provider invalidates authorization codes when there is an error in the token exchange.
Inherited from¶
BaseOAuthAuthentication.credentialsLocation
endpointDomain?¶
optionalendpointDomain:string
Defined in: types.ts:283
When requiresEndpointUrl is set to true this should be the root domain that all endpoints share. For example, this value would be "example.com" if specific endpoints looked like {custom-subdomain}.example.com.
For packs that make requests to multiple domains (uncommon), this should be the domain within PackVersionDefinition.networkDomains that this configuration applies to.
Inherited from¶
BaseOAuthAuthentication.endpointDomain
endpointKey?¶
optionalendpointKey:string
Defined in: types.ts:588
In rare cases, OAuth providers will return the specific API endpoint domain for the user as part of the OAuth token exchange response. If so, this is the property in the OAuth token exchange response JSON body that points to the endpoint.
The endpoint will be saved along with the account and will be available during execution as ExecutionContext.endpoint.
getConnectionName?¶
optionalgetConnectionName:MetadataFormula
Defined in: types.ts:251
A function that is called when a user sets up a new account, that returns a name for the account to label that account in the UI. The users credentials are applied to any fetcher requests that this function makes. Typically, this function makes an API call to an API's "who am I" endpoint and returns a username.
If omitted, or if the function returns an empty value, the account will be labeled with the creating user's Coda username.
Inherited from¶
BaseOAuthAuthentication.getConnectionName
instructionsUrl?¶
optionalinstructionsUrl:string
Defined in: types.ts:266
A link to a help article or other page with more instructions about how to set up an account for this pack.
Inherited from¶
BaseOAuthAuthentication.instructionsUrl
nestedResponseKey?¶
optionalnestedResponseKey:string
Defined in: types.ts:518
In rare cases, OAuth providers send back access tokens nested inside another object in their authentication response.
Inherited from¶
BaseOAuthAuthentication.nestedResponseKey
networkDomain?¶
optionalnetworkDomain:string|string[]
Defined in: types.ts:297
Which domain(s) should get auth credentials, when a pack is configured with multiple domains. Packs configured with only one domain or with requiresEndpointUrl set to true can omit this.
Using multiple authenticated network domains is uncommon and requires Coda approval.
Inherited from¶
BaseOAuthAuthentication.networkDomain
pkceChallengeMethod?¶
optionalpkceChallengeMethod:"plain"|"S256"
Defined in: types.ts:605
See useProofKeyForCodeExchange
postSetup?¶
optionalpostSetup:SetEndpoint[]
Defined in: types.ts:289
One or more setup steps to run after the user has set up the account, before completing installation of the pack. This is not common.
Inherited from¶
BaseOAuthAuthentication.postSetup
requiresEndpointUrl?¶
optionalrequiresEndpointUrl:boolean
Defined in: types.ts:274
If true, indicates this has pack has a specific endpoint domain for each account, that is used
as the basis of HTTP requests. For example, API requests are made to
Inherited from¶
BaseOAuthAuthentication.requiresEndpointUrl
scopeDelimiter?¶
optionalscopeDelimiter:" "|","|";"
Defined in: types.ts:509
The delimiter to use when joining scopes when generating authorization URLs.
The OAuth2 standard is to use spaces to delimit scopes, and Coda will do that by default. If the API you are using requires a different delimiter, say a comma, specify it here.
Inherited from¶
BaseOAuthAuthentication.scopeDelimiter
scopeParamName?¶
optionalscopeParamName:string
Defined in: types.ts:502
In rare cases, OAuth providers may want the permission scopes in a different query parameter
than scope.
Inherited from¶
BaseOAuthAuthentication.scopeParamName
scopes?¶
optionalscopes:string[]
Defined in: types.ts:497
Scopes that are required to use this pack.
Each API defines its own list of scopes, or none at all. You should consult the documentation for the API you are connecting to.
Inherited from¶
BaseOAuthAuthentication.scopes
tokenPrefix?¶
optionaltokenPrefix:string
Defined in: types.ts:533
A custom prefix to be used when passing the access token in the HTTP Authorization
header when making requests. Typically this prefix is Bearer which is what will be
used if this value is omitted. However, some services require a different prefix.
When sending authenticated requests, a HTTP header of the form
Authorization: <tokenPrefix> <token> will be used.
Inherited from¶
BaseOAuthAuthentication.tokenPrefix
tokenQueryParam?¶
optionaltokenQueryParam:string
Defined in: types.ts:539
In rare cases, OAuth providers ask that a token is passed as a URL parameter rather than an HTTP header. If so, this is the name of the URL query parameter that should contain the token.
Inherited from¶
BaseOAuthAuthentication.tokenQueryParam
tokenUrl¶
tokenUrl:
string
Defined in: types.ts:513
The URL that Coda will hit in order to exchange the temporary code for an access token.
Inherited from¶
BaseOAuthAuthentication.tokenUrl
type¶
type:
OAuth2
Defined in: types.ts:565
Identifies this as OAuth2 authentication.
useProofKeyForCodeExchange?¶
optionaluseProofKeyForCodeExchange:boolean
Defined in: types.ts:600
Option to apply PKCE (Proof Key for Code Exchange) OAuth2 extension. With PKCE extension,
a code_challenge parameter and a code_challenge_method parameter will be sent to the
authorization page. A code_verifier parameter will be sent to the token exchange API as
well.
code_challenge_method defaults to SHA256 and can be configured with pkceChallengeMethod.
See https://datatracker.ietf.org/doc/html/rfc7636 for more details.