OAuth 2.0 configuration: Securely storing access tokens
OAuth 2.0 (Open Authorization) is a widely adopted standard for authorization that allows users to grant access to their accounts on one service (like Google or GitHub) to another application (like your DevRev snap-in) without needing to share their passwords directly. This approach enhances security and user convenience.
For comprehensive information about the OAuth specification, refer to the official documentation: OAuth 2.0.
Using OAuth 2.0 keyrings
-
Define the keyring: Within your snap-in manifest, define a keyring specifically for OAuth credentials. DevRev offers pre-defined keyring types for popular services like Slack or Jira, simplifying the process.
-
Provide credentials: During development, you’ll provide your developer keyring of type
oauth-secret
which contains client ID and client secret for the chosen service within the keyring definition. These credentials are securely stored and not distributed with your published snap-in. -
OAuth 2.0 flow: When your snap-in needs to access user data from the external service, it initiates the OAuth flow. This typically involves redirecting the user to the service’s login page and then back to your snap-in after successful authorization.
-
Access tokens: Upon successful authorization, the service provides your snap-in with an access token. This token is used to access user data on the service’s behalf without requiring the user’s password again.
-
Refreshing tokens: A key benefit of using keyrings for OAuth is that they can handle refreshing access tokens automatically. Most OAuth implementations issue a refresh token alongside the access token. This refresh token can be used to obtain a new access token before the current one expires. If the token is not provided or is expired, the user will need to re-authorize the connection.
-
Revoking tokens: For enhanced security, you can also configure your keyring to revoke access tokens when they are no longer needed. This ensures that even if a token is compromised, it can’t be used to access user data.
-
Organization data: Optionally, you can configure your keyring to fetch additional information about the user’s organization within the service. This can be useful for snap-ins that need to access organization-wide data.
Keywords
The supported keywords that can be dynamically inserted into URLs, headers, and query parameters within your custom keyring type configuration.
[ACCESS_TOKEN]
: The access token obtained during the OAuth flow.[REFRESH_TOKEN]
: The refresh token obtained during the OAuth flow.[CLIENT_ID]
: The client ID obtained from the OAuth client credentials.[CLIENT_SECRET]
: The client secret obtained from the OAuth client credentials.[SCOPE]
: The scope of the OAuth flow.[API_KEY]
: The API key obtained from the basic flow.
Syntax
Here, you can refer to the keyring type examples.