OAuthService
The OAuthService
class is designed to abstract the OAuth authorization process using the PKCE (Proof Key for Code Exchange) flow, simplifying the integration with various OAuth providers such as Asana, GitHub, and others.
Use OAuthServiceOptions to configure the OAuthService
class.
Example
Signature
Methods
authorize
authorize
Initiates the OAuth authorization process or refreshes existing tokens if necessary. Returns a promise that resolves with the access token from the authorization flow.
Signature
Example
Built-in Services
Some services are exposed as static properties in OAuthService
to make it easy to authenticate with them:
Asana, GitHub, Linear, and Slack already have an OAuth app configured by Raycast so that you can use them right of the box by specifing only the permission scopes. You are still free to create an OAuth app for them if you want.
Google, Jira and Zoom don't have an OAuth app configured by Raycast so you'll have to create one if you want to use them.
Use ProviderOptions or ProviderWithDefaultClientOptions to configure these built-in services.
Asana
Signature
Example
GitHub
Signature
Example
Google
Google has verification processes based on the required scopes for your extension. Therefore, you need to configure your own client for it.
Creating your own Google client ID is more tedious than other processes, so we’ve created a page to assist you: Getting a Google client ID
Signature
Example
Jira
Jira requires scopes to be enabled manually in the OAuth app settings. Therefore, you need to configure your own client for it.
Signature
Example
Linear
Signature
Example
Slack
Signature
Example
Zoom
Zoom requires scopes to be enabled manually in the OAuth app settings. Therefore, you need to configure your own client for it.
Signature
Example
Types
OAuthServiceOptions
Property Name | Description | Type |
---|---|---|
client* | The PKCE Client defined using |
|
clientId* | The app's client ID |
|
scope* | The scope of the access requested from the provider |
|
authorizeUrl* | The URL to start the OAuth flow |
|
tokenUrl* | The URL to exchange the authorization code for an access token |
|
refreshTokenUrl | The URL to refresh the access token if applicable |
|
personalAccessToken | A personal token if the provider supports it |
|
onAuthorize | A callback function that is called once the user has been properly logged in through OAuth when used with |
|
extraParameters | The extra parameters you may need for the authorization request |
|
bodyEncoding | Specifies the format for sending the body of the request. |
|
tokenResponseParser | Some providers returns some non-standard token responses. Specifies how to parse the JSON response to get the access token |
|
tokenRefreshResponseParser | Some providers returns some non-standard refresh token responses. Specifies how to parse the JSON response to get the access token |
|
ProviderOptions
Property Name | Description | Type |
---|---|---|
clientId* | The app's client ID |
|
scope* | The scope of the access requested from the provider |
|
authorizeUrl* | The URL to start the OAuth flow |
|
tokenUrl* | The URL to exchange the authorization code for an access token |
|
refreshTokenUrl | The URL to refresh the access token if applicable |
|
personalAccessToken | A personal token if the provider supports it |
|
onAuthorize | A callback function that is called once the user has been properly logged in through OAuth when used with |
|
bodyEncoding | Specifies the format for sending the body of the request. |
|
tokenResponseParser | Some providers returns some non-standard token responses. Specifies how to parse the JSON response to get the access token |
|
tokenRefreshResponseParser | Some providers returns some non-standard refresh token responses. Specifies how to parse the JSON response to get the access token |
|
ProviderWithDefaultClientOptions
Property Name | Description | Type |
---|---|---|
scope* | The scope of the access requested from the provider |
|
clientId | The app's client ID |
|
authorizeUrl | The URL to start the OAuth flow |
|
tokenUrl | The URL to exchange the authorization code for an access token |
|
refreshTokenUrl | The URL to refresh the access token if applicable |
|
personalAccessToken | A personal token if the provider supports it |
|
onAuthorize | A callback function that is called once the user has been properly logged in through OAuth when used with |
|
bodyEncoding | Specifies the format for sending the body of the request. |
|
tokenResponseParser | Some providers returns some non-standard token responses. Specifies how to parse the JSON response to get the access token |
|
tokenRefreshResponseParser | Some providers returns some non-standard refresh token responses. Specifies how to parse the JSON response to get the access token |
|
Last updated