I'm creating my own OAuth 2.0 endpoints and using Apigee's OAuth 2.0 Policies to generate and manage authorization codes and tokens. The documentation specifies all possible error codes and error descriptions when OAuth 2.0 policies fail (at http://apigee.com/docs/gateway-services/api/oauth-error-code-reference), however it does not say which flow variables will contain the corresponding error code and error description. Documentation at http://apigee.com/docs/api-services/api/oauth-flow-variables does not help either... it just explains the flow variables set on success.
I DON'T want to use the GenerateResponse
tag in my OAuth policies, so I need to access the error code and error description in case the OAuth policy fails.
What variables are set when an OAuth policy fails?? how to know that an OAuth policy has failed?
so far, I know that variable fault.name
seems to have the error code, but the error description is not in error.message
variable.
Sample Policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OAuthV2 async="false" continueOnError="false" enabled="true" name="OAuth-Exchange-Code-with-Token">
<DisplayName>OAuth Exchange Code with Token</DisplayName>
<Operation>GenerateAccessToken</Operation>
<!-- This is in millseconds, so expire in an hour -->
<ExpiresIn>3600000</ExpiresIn>
<ReuseRefreshToken>false</ReuseRefreshToken>
<RefreshTokenExpiresIn>3600000</RefreshTokenExpiresIn>
<SupportedGrantTypes>
<GrantType>authorization_code</GrantType>
</SupportedGrantTypes>
<GenerateResponse enabled="false"/>
</OAuthV2>
if the above policy fails, since <GenerateResponse enabled="false"/>
is disabled, I like to produce a response myself in a <FaultRules>
and access the actual error description such as "Client Credentials required". But there is no flow variables to access the error description.