Add OAuth v2.0 Policy to Verify Access Tokens
Attach an OAuth v2.0 policy in VerifyAccessToken mode to the actual API Proxy. This ensures only requests with a valid token (issued by the token proxy) can access iCWP APIs.
To add OAuth v2.0 policy:
- Select API proxy and click Policies.
- Click Edit.
- Select ProxyEndpoint.
- Select PreFlow.
- Under Security Policies, choose OAuth v2.0.
- Click on the + button to add the policy.
- Enter the Policy Name, set the Stream as Incoming Request and click Add.
-
Replace the existing default content in the Body section with the following
policy XML and click Update.
Policy Message:
<OAuthV2 async="false" continueOnError="false" enabled="true" xmlns="http://www.sap.com/apimgmt"> <!-- By default, VerifyAccessToken expects the access token to be sent in an Authorization header. You can change that default using this element<AccessToken> --> <!-- If you want to pass access token in an customer header "access_token": --> <!-- <AccessToken>request.header.access_token</AccessToken> --> <!-- If you want to pass access token in query param "access_token": --> <!-- <AccessToken>request.queryparam.access_token</AccessToken> --> <!-- this flag has to be set when you want to work with third-party access tokens --> <ExternalAuthorization>false</ExternalAuthorization> <!-- valid values are GenerateAccessToken, GenerateAccessTokenImplicitGrant, GenerateAuthorizationCode , RefreshAccessToken , VerifyAccessToken , InvalidateToken , ValidateToken --> <Operation>VerifyAccessToken</Operation> <GenerateResponse enabled="true"/><SupportedGrantTypes/> <Tokens/> </OAuthV2>
-
Click Save.
The Verify OAuth Access Token policy should be placed first in the execution flow. You can change its position by clicking on the navigation arrows.