Skip to Content

In this blog, we will generate and consume SCP OAuth token in the Data Quality API using policies. As described in the previous blog Part 3 of this series don’t have to generate OAuth token separately

1.  Open Data Quality API which is created as per our previous blog, click on the Policies button

2. Policy editor comes up in read-only mode, switch to edit-mode by clicking on the Edit button

3. We will use Service Callout policy to generate OAuth token, add GetOAuthToken(Service Callout) policy on the PreFlow of the target endpoint

GetOAuthToken-code snippet:

Provide your SCP OAuth token generation URL in the Service callout policy as shown in the above screenshot.

4. To pass credential to OAuth Token endpoint, add  Assign Message & Basic Authentication policies before the Service Callout policy.

GetCredential(Assign Message) policy will store credential and Authorization(Basic Authentication) policy will encode credentials

 

GetCredential-code snippet

Authorisation-code snippet

5. To read the generated OAuth token use extract variable policy. Adding ReadAccessToken(Extract variable) policy after GetOAuthToken.

5.  Finally, let’s provide the OAuth token to the target endpoint by using assign message policy.              Add the SetAccessToken(Assign Message) policy on the Post-flow(incoming request) of the                target endpoint

 

SetAccessToken-code snippet

7.  Save the API, now let’s see if we get the desired result 🙂

As you have already explored API in the API Business Hub, similarly go to the Resources tab in the API & click on GET button of the refData_country.

API Test Console comes, now click on the Send button to see the response.

In the next blog part 5 of this series, we will use API Management Policy Template to achieve the same result, policy template available in the SAP API Business Hub.

 

 

 

 

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply