OAuth2 Client
The Rocket.Chat App OAuth2 workflow is a feature that lets developers handle OAuth2 authentication on their apps directly within Rocket.Chat
OAuth2 Setup
Import the methods needed from the
IOAuth2
andOAuth2
definitions in the main class of your app.
When setting up the app configurations using the
extendConfiguration
method, we create an instance of thecreateOAuth2Client
imported above.
The
createOAuth2Client
method takes in two parameters:app
: The app itself.options
: An object with props as configuration - see the definition documentation for more details.
Now calling the
setup(configuration)
method on thecreateOAuth2Client
creates all the setup APIs you need to use.
Use OAuth2
After setup, use the OAuth2Client
to access multiple methods like getAccessTokenForUser
, revokeUserAccessToken
etc.
getAccessTokenForUser
getAccessTokenForUser
Gets the token information for a specific user, if available. This receives the user instance as a parameter and returns data about the authenticated user.
getUserAuthorizationUrl
getUserAuthorizationUrl
Returns the authorization URL to which the user must be redirected in order to authorize access to the application.
refreshUserAccessToken
refreshUserAccessToken
Refreshes the user's access token. This is useful when the user access token has expired.
revokeUserAccessToken
revokeUserAccessToken
Revokes user's access token in the service provider. When successfully executed, users will need to be authenticated again before using the service.
Last updated