In this Article
Table of Contents | ||||
---|---|---|---|---|
|
...
Log into the Coupa portal.
Navigate to Setup > Integrations > Oauth2/OpenID Connect Clients.
Note: You can also search for ‘oauth’ in the Find it fast search box.Click Create in Oauth2/OpenID Connect Clients page.
From the Grant type list, select Client credentials.
Specify the details for the client as shown in the image below:
Note: You must provide a unique login id for Client Credentials Grant type,else Coupa displays an error,
Login has already been taken
.Select the Scopes you want to include in this API setup. To create a client app, we must select at least one scope and the scopes which provide access to specific APIs required for your functionality. Click the Scope to view the APIs that each Scope supports.
Note: To implement API permissions with OIDC, we've created several new scopes that provide access to specific functionality for the API.Click Save to save the client.
The client Identifier and Secret are generated to gain access to the API Scopes that you have configured. Toggle Show/Hide to display and copy the client secret.
Configuring an OAuth App with Authorization Code Grant type
...
Steps 1 through 3 are common as mentioned in Configuring an OAuth App with Client Credentials Grant type.
From the Grant type list, select Authorization code.
Specify the details for the client as shown in the image below.
Mandatory. Select
offline_access
scope under Scopes.Click Save. The client Identifier and Secret are generated.
...
Requesting an OpenID Connect access token
Once you have created a client, the next step is to request for an access token. The access token request for your client varies based on the grant type you have chosen.
...
Requesting an Access Token for Client credentials Grant type
This grant type is used when there is no user involved; typically used for system-to-system integrations. Token is automatically accepted and generated. Client credentials requires no consent and a HTTPS POST request can be made directly to Coupa. Below is an example of
Info |
---|
The following example is a request for an access token using curl: |
...
|
The response from the curl command is a JSON object that contains the access token.
Requesting an Access Token for Authorization code Grant type
This grant type is used when an end user is involved. It requires the user's consent before granting an access token to be used to access resources. In a web browser, enter
Enter the following URL in the address bar of the browser, (
...
replace the elements between parenthesis with the correct values). The consent screen is displayed.
...
<https://<INSTANCE_DOMAIN>/oauth2/authorizations/new?client_id=<CLIENT_ID>&response_type=code&scope=<SPACE_SEPARATED_LIST_OF_SCOPES>&redirect_uri=<REDIRECT_
...
URI>>
Click Allow. You are redirected to the REDIRECT_URI specified when you created the client. The redirect URI contains a CODE that the client can use to retrieve the access token.
To retrieve the access token with the code, you must make a HTTPS POST.
...
The response from the curl command is a JSON object that contains the access token.The following example is a request using curl:
...
curl
...
-XPOST
...
-i
...
<https://<INSTANCE_DOMAIN>/oauth2/token?client_id=<CLIENT_ID>&grant_type=authorization_code&code=<CODE>&scope=<SPACE_SEPARATED_LIST_OF_SCOPES>&client_secret=<CLIENT_SECRET>&redirect_uri=<REDIRECT_
...
URI>>
Authorization code with PKCE (Proof Key for Code Exchange)
The PKCE-enhanced Authorization Code Flow is used to have an additional security layer for authentication. This flow introduces a secret code created by the calling application that can be is verified by the authorization server; this secret is called the Code Verifier. Additionally, the calling app application creates a transform value of the Code Verifier called the Code Challenge and sends this value over HTTPS to retrieve an Authorization Code. This way, a malicious attacker can only intercept the Authorization Code, and they cannot exchange it for a token without the Code Verifier.
code_verifier — The code verifier should be a high-entropy cryptographic random string with a minimum of 43 characters and a maximum of 128 characters. Should only use A-Z, a-z, 0–9, “-”(hyphen), “.” (period), “_”(underscore), “~”(tilde) characters.
code_challenge — The code challenge is created by SHA256 hashing the code_verifier and base64 URL encoding the resulting hash
Base64UrlEncode(SHA256Hash(code_verifier))
. And each pair is used only once.code_challenge = BASE64URL-ENCODE(SHA256(ASCII(code_verifier))).
code_challenge_method — it’s used to state the method (the available value is “S256”) used to transform the code verifier into the code challenge and if you don’t use it an Authorization Server will assume that the code challenge and the code verifier are the same.
Expected error’s when using code verifier/challenge :
If code _verifier and code code _challenge will mismatch leads to below mismatch, it displays the following error and each pair is used only once.
Device code
This grant type is used in cases where the client resides on a device and the user gets authenticated and authorizes the request on another. The device asks the user to go to a link on their computer or smartphone and authorize the device. Device code requires a HTTPS POST request to be made. Below is an example of a request for an access token using curl:
Paste code macro |
---|
curl -XPOST -i https://<INSTANCE_DOMAIN>/oauth2/device_authorizations?client_id=<CLIENT_ID>&scope=<SPACE_SEPARATED_LIST_OF_SCOPES>
|
The curl request above is a JSON response containing the verification_uri
and user code among other values. Go to the verification_uri
on a browser and enter the user code to complete the flow.
Scopes
Coupa scopes take the form of service.object.right
. For example, core.accounting.read
or core.accounting.write
. You can find the list of scopes and their underlying Coupa permissions by navigating to the Scope management page at /oauth2/scopes
in Coupa. When you drill down into a scope, you can see the specific API permissions associated with that scope.
...
Grant Types | Scope without offline_access | Scope with offline_access |
---|---|---|
Client Credentials grant type | Provides only access token and expiry | Provides only access token and expiry |
Authorization Code shared secret | Provides only access token and expiry | Provides access token, expiry and refresh token. |
Authorization code PKCE | Provides only access token and expiry | Provides access token, expiry and refresh token.
|
Locate/Define Information Required to Create your
...
Coupa OAuth2 Account
Specify the values required to create a successful <Snap Pack Name> OAuth2 account.
Navigate to the <Snap Pack Name> Snap of your choice and configure the <Snap Pack Name> OAuth2 Account with the following details:
Client ID: A Public Identifier for your app. Provide the Client ID that is auto-generated after creating the app in the <endpoint>
Client Secret: Secret value known only to the app and the auth server. Provide the Client Secret that is auto-generated after creating the app in the <endpoint>.
OAuth2 Endpoint:
OAuth2 Token:
<Insert Account image>
Click Authorize.
You will be redirected to the login page of ServiceNow.Log into ServiceNow Coupa and accept the permissions.
The Access token and the Refresh Token will be generated.Select the Auto-refresh token checkbox and save the account.