Authorize external requests using authorization code grant
OAuth 2.0 is one of the supported authorization types in Creatio. This technology does not pass Creatio logins and passwords to external apps. Identity Service implements OAuth 2.0 in Creatio and authorizes external apps and web services you integrate with Creatio using OAuth 2.0. OAuth 2.0 also lets you restrict Creatio permissions for the integrated apps. For example, you can use OAuth 2.0 authorization to integrate webhook service, Power BI Connector, Clio, Creatio.ai add-in for Outlook with Creatio. Learn more: official vendor documentation (OAuth 2.0).
Before you authorize external requests to Creatio, set up OAuth authorization of authorization code grant. Instructions: Set up authorization code grant (user documentation).
This article covers setup procedure to authorize external requests using authorization code grant. Creatio also supports client credentials grant. Learn more: Authorize external requests using client credentials grant.
General procedure
- Retrieve an authorization code. Read more >>>
- Retrieve access and refresh OAuth tokens. Read more >>>
1. Retrieve an authorization code
Learn more about authorization code: Authorization Code (OAuth 2.0 Authorization Framework).
To retrieve an authorization code:
-
Find the endpoint to retrieve an authorization code. To do this, access the
{CreatioURL}/0/.well-known/openid-configurationURL from the browser. This discovery endpoint displays a list of all OAuth endpoints available for your Creatio instance. Theauthorization_endpointparameter includes the endpoint to retrieve an authorization code.If an external app to integrate with Creatio supports the discovery endpoint or you develop a custom external app, you can use the discovery endpoint to receive OAuth endpoints dynamically without storing this value in your external app.
-
Create a request.
-
Access the
/connect/authorizeendpoint. -
Fill out the parameters of the request string.
Parameter
Description
client_id*
The
ClientIdparameter value retrieved while configuring authorization code grant. Find the parameter value in the Client Id field on the integration page. Learn more: Generate OAuth 2.0 client credentials (user documentation).redirect_uri*
Redirect URIs to receive authorization codes when authorizing an integrated app. Find the parameter value in the Authorized redirect URIs expanded list on the integration page.
response_type*
Requires the
codeparameter value.scope*
The scope of the request execution. Represents the list of permissions that the external app receives after granting the consent. Creatio supports the following scopes:
- offline access to work with OAuth refresh token
- application access to access Creatio instance inside context of user who grants consent. Application access value is unique for each Creatio instance. Find the parameter value in the Name column of the OAuth resource lookup. Since version 8.3.4, the
ApplicationAccessscope is not required in the authorization code grant request. Creatio adds it to the issued token by default after authorization. To use this functionality, enable theAddApplicationAccessScopeAutomaticallyadditional feature.
Use percent-encoded space ("%20") as a delimiter of scope list.
state*
- If you use an existing external app, the external app must populate the
stateparameter value. - If you use a custom external app, implement business logic that generates an arbitrary sequence of characters every time you use the
stateparameter to ensure CSRF protection. Ensure that Creatio returns the same value of thestateparameter to the custom external app after the user confirms access to Creatio from the integrated app. If returned and sent parameter values are different, recognize it as a potential attack.
The following example requests an authorization code below.
Request stringGET {CreatioURL}/0/connect/authorize?client_id=7******3&redirect_uri=https://SomeRedirectURL&response_type=code&scope=offline_access%20ApplicationAccess_2******e&state=xyz
-
-
Execute the request.
- For a browser external app, execute the request in a new browser tab or perform redirect in the current tab.
- For a desktop external app, open a separate browser window whose size is no smaller than 730x560 pixels to display the consent page.
As a result:
- The user will be redirected to the Creatio login page.
- When the user logs in to the Creatio instance, Creatio will confirm the validity of the user credentials and redirect the user to the consent page.
- When the user confirms access to Creatio from the integrated app, Creatio will pass the authorization code to the external app using the specified redirect URI.
You can now retrieve access and refresh OAuth tokens. Learn more: Access Token, Refresh Token (OAuth 2.0 Authorization Framework).
2. Retrieve access and refresh OAuth tokens
-
Find the endpoint to retrieve access and refresh OAuth tokens. To do this, access the
{CreatioURL}/0/.well-known/openid-configurationURL from the browser. This discovery endpoint displays a list of all OAuth endpoints available for your Creatio instance. Thetoken_endpointparameter includes the endpoint to retrieve access and refresh OAuth tokens. -
Create a request.
-
Access the
/connect/tokenendpoint. -
Fill out the parameters of the request string.
Parameter
Description
client_id*
The
ClientIdparameter value retrieved while configuring authorization code grant. Find the parameter value in the Client Id field on the integration page. Learn more: Generate OAuth 2.0 client credentials (user documentation).client_secret*
The
Client secretparameter value retrieved while configuring authorization code grant. Find the parameter value in the Client secret field on the integration page. Learn more: Generate OAuth 2.0 client credentials (user documentation).grant_type*
OAuth 2.0 authorization type. Find the parameter value in the Grant type column on the OAuth integrated applications page. Requires the
authorization_codevalue of thegrantTypeparameter to retrieve access and refresh OAuth tokens for authorization code grant.scope*
The scope of the request execution. Represents the list of permissions that the external app receives after granting the consent. Creatio supports the following scopes:
- offline access to work with OAuth refresh token
- application access to access Creatio instance inside context of user who grants consent. Application access value is unique for each Creatio instance. Find the parameter value in the Name column of the OAuth resource lookup. Since version 8.3.4, the
ApplicationAccessscope is not required in the authorization code grant request. Creatio adds it to the issued token by default after authorization. To use this functionality, enable theAddApplicationAccessScopeAutomaticallyadditional feature.
Use percent-encoded space ("%20") as a delimiter of scope list.
redirect_uri*
Redirect URIs to receive authorization codes when authorizing an integrated app. Find the parameter value in the Authorized redirect URIs expanded list on the integration page.
code*
The authorization code retrieved on the previous step.
content-type*
Requires the
application/x-www-form-urlencodedparameter value.The following example requests access and refresh OAuth tokens below.
Request stringPOST {CreatioURL}/0/connect/token?client_id=7******3&client_secret=2******6&grant_type=authorization_code&scope=offline_access%20ApplicationAccess_2******e&state=xyz&redirect_uri=https://SomeRedirectURL&code=0******FContent-Type: application/x-www-form-urlencoded
-
-
Execute the request.
As a result, Creatio will confirm the validity of the authorization code and OAuth 2.0 client credentials and return the access and refresh OAuth tokens to authorize external requests using authorization code grant.
The access and refresh OAuth tokens used by authorization code grant have a finite lifetime out of the box:
- 3 minutes for access token
- 48 hours for refresh token
Update access and refresh OAuth tokens
Update access and refresh OAuth tokens to maintain the connection between the external app and Creatio. When the refresh token expires, retrieve it again. Read more >>>
To update access and refresh OAuth tokens:
-
Find the endpoint to update access and refresh OAuth tokens. To do this, access the
{CreatioURL}/0/.well-known/openid-configurationURL from the browser. This discovery endpoint displays a list of all OAuth endpoints available for your Creatio instance. Thetoken_endpointparameter includes the endpoint to update access and refresh OAuth tokens. -
Create a request.
-
Access the
/connect/tokenendpoint. -
Fill out the parameters of the request string.
Parameter
Description
client_id*
The
ClientIdparameter value retrieved while configuring authorization code grant. Find the parameter value in the Client Id field on the integration page. Learn more: Generate OAuth 2.0 client credentials (user documentation).client_secret*
The
Client secretparameter value retrieved while configuring authorization code grant. Find the parameter value in the Client secret field on the integration page. Learn more: Generate OAuth 2.0 client credentials (user documentation).grant_type*
Requires the
refresh_tokenparameter value.scope*
The scope of the request execution. Represents the list of permissions that the external app receives after granting the consent. Creatio supports the following scopes:
- offline access to work with OAuth refresh token
- application access to access Creatio instance inside context of user who grants consent. Application access value is unique for each Creatio instance. Find the parameter value in the Name column of the OAuth resource lookup. Since version 8.3.4, the
ApplicationAccessscope is not required in the authorization code grant request. Creatio adds it to the issued token by default after authorization. To use this functionality, enable theAddApplicationAccessScopeAutomaticallyadditional feature.
Use percent-encoded space ("%20") as a delimiter of scope list.
redirect_uri*
Redirect URIs to receive authorization codes when authorizing an integrated app. Find the parameter value in the Authorized redirect URIs expanded list on the integration page.
refresh_token*
The OAuth refresh token retrieved on the previous step.
content-type*
Requires the
application/x-www-form-urlencodedparameter value.The following example updates an OAuth refresh token below.
Request stringPOST {CreatioURL}/0/connect/token?client_id=7******3&client_secret=2******6&grant_type=refresh_token&scope=offline_access%20ApplicationAccess_2******e&state=xyz&redirect_uri=https://SomeRedirectURL&refresh_token=D******5Content-Type: application/x-www-form-urlencoded
-
-
Execute the request.
As a result, Creatio will return updated access and refresh OAuth tokens to authorize external requests using authorization code grant.
Revoke an OAuth refresh token
Revoke an OAuth refresh token to implement a logout feature in a custom external app that disconnects the external app from the Creatio account. To establish connection, retrieve an authorization code. Read more >>>
To revoke an OAuth refresh token:
-
Find the endpoint to revoke an OAuth refresh token. To do this, access the
{CreatioURL}/0/.well-known/openid-configurationURL from the browser. This discovery endpoint displays a list of all OAuth endpoints available for your Creatio instance. Therevocation_endpointparameter includes the endpoint to revoke an OAuth refresh token. -
Create a request.
-
Access the
/connect/revocationendpoint. -
Fill out the parameters of the request string.
Parameter
Description
client_id*
The
ClientIdparameter value retrieved while configuring authorization code grant. Find the parameter value in the Client Id field on the integration page. Learn more: Generate OAuth 2.0 client credentials (user documentation).client_secret*
The
Client secretparameter value retrieved while configuring authorization code grant. Find the parameter value in the Client secret field on the integration page. Learn more: Generate OAuth 2.0 client credentials (user documentation).token*
The OAuth refresh token to revoke.
token_type_hint
Requires the
refresh_tokenparameter value.content-type*
Requires the
application/x-www-form-urlencodedparameter value.The following example updates an OAuth refresh token below.
Request stringPOST {CreatioURL}/0/connect/revocation?client_id=7******3&client_secret=2******6&token=2******1&token_type_hint=refresh_tokenContent-Type: application/x-www-form-urlencoded
-
-
Execute the request.
As a result, Creatio will return the following:
- 200 OK status code if the OAuth refresh token is revoked or non-existent.
- 4xx client error status code if an error occurs while processing the request.
See also
Set up authorization code grant (user documentation)
Resources
Official vendor documentation (OAuth 2.0 Authorization Framework)