Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member37862
Product and Topic Expert
Product and Topic Expert
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.

 

 

 

 
1 Comment