Skip to main content

OAuth2

The oauth2 component is used to authenticate with an OAuth 2.0 server. The component sends the user to the authorization server to authenticate and receive an access token. The access token is used to authenticate the user with the application. The component can be used to authenticate with any OAuth 2.0 server.

Token must be stored in the application state to be used in the application. The onToken event is used to store the token in the application state.

Usage

components:
- name: "oauth2"
description: "oAuth2"
props:
label:
en-US: "Authenticating with OAuth 2.0"
clientId: "client-id"
clientSecret: "client-secret"
authorizationUrl: "https://example.com/oauth2/authorize"
tokenUrl: "https://example.com/oauth2/token"
scopes:
- "read"
- "write"
additionalParams: # additional parameters to be sent to the authorization server
app_name: "myapp"
additionalHeaders: # additional headers to be sent to the authorization server
app_name: "myapp"
onToken:
setData:
token: "{{ token }}"

Redirect Url

The redirect URL of the application must be set to the URL of the application with the path /oauth2/callback. For example, if the application is running on http://tms.example.com, the redirect URL must be set to http://tms.example.com/oauth2/callback.

Add this URL to the list of redirect URLs in the application settings of the authorization server.

Props

  • label : The label of the component.
  • clientId : The client id of the application.
  • clientSecret : The client secret of the application.
  • authorizationUrl : The URL of the authorization server.
  • tokenUrl : The URL of the token server.
  • scopes : The scopes of the application.
  • additionalParams : Additional parameters to be sent to the authorization server.
  • additionalHeaders : Additional headers to be sent to the authorization
  • onToken : The event to be triggered when the token is received. The response of the token server is stored in the token variable.