I am using below code to set an attributes in OAuth2.0. The attribute is passed as QueryParam to the proxy end point.
I have another endpoint in same proxy where I have to get this attribute value .
How can I read this value in another endpoint within same proxy ?
Do I need to use ' GetOAuthV2Info policy' and then 'Assign Message Policy' or is there any other way ?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <OAuthV2 continueOnError="false" enabled="true" name="OA-GenerateAuthCode"> <DisplayName>OA-GenerateAuthCode</DisplayName> <Properties/> <ExternalAuthorization>false</ExternalAuthorization> <Operation>GenerateAuthorizationCode</Operation> <Attributes> <Attribute name="originating_code_challenge" ref="request.queryparam.code_challenge" display="true"/> </Attributes> <GenerateResponse enabled="true"/> <Tokens/> </OAuthV2>
Once the token validation happens, all the attributes will be available in the flow.
You can use GetOAuth2Info policy on the code:
https://docs.apigee.com/api-platform/reference/policies/get-oauth-v2-info-policy
<GetOAuthV2Info async="false" continueOnError="false" enabled="true" name="OA-GetAuthCodeAttributes"> <DisplayName>OA-GetAuthCodeAttributes</DisplayName> <AuthorizationCode ref="request.formparam.code"/> </GetOAuthV2Info>
After that policy executes you'll be able to access any custom attribute e.g. external_code using the pattern below.
{oauthv2authcode.OA-GetAuthCodeAttributes.external_code}
User | Count |
---|---|
3 | |
2 | |
1 | |
1 | |
1 |