Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Error while trying to get Oauth Access token using authorization_code as grant type

Not applicable

Hi Friends,

I am trying to implement three legged oauth with the sample proxies given at https://github.com/apigee/api-platform-samples/tree/master/sample-proxies/oauth-advanced. When I tried to call the generate Access token flow to get acces token through postman, with the auth code generated I got the following response.

{ "fault": { "faultstring": "invalid_request", "detail": { "errorcode": "invalid_request" } } }

My Request is as follows:

URL: https://{myorg}-test.apigee.net/oauth2/token?code=Vo3x7VSc&grant_type=authorization_code&redirect_ur...

With header,

Authorization : Basic base64(client_id:client_secret)

In trace I found an error after GenerateAccessToken Policy like:

error invalid_request
error.class com.apigee.oauth.v2.TokenGenerationException
Identifier fault
proxy.flow.name AccessTokenRequest
state PROXY_REQ_FLOW
type ErrorPoint

My generateAccessToken policy is as follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <OAuthV2 async="false" continueOnError="false" enabled="true" name="AccessTokenRequest">

<DisplayName>AccessTokenRequest</DisplayName>

<ExpiresIn>3600000</ExpiresIn>

<ExternalAuthorization>false</ExternalAuthorization>

<Operation>GenerateAccessToken</Operation> <GenerateResponse enabled="false">

<Format>FORM_PARAM</Format>

</GenerateResponse>

<ReuseRefreshToken>false</ReuseRefreshToken>

<SupportedGrantTypes>

<GrantType>authorization_code</GrantType>

<GrantType>client_credentials</GrantType>

</SupportedGrantTypes>

<Tokens/>

</OAuthV2>

Can anyone suggest where I went wrong?

0 3 1,514
3 REPLIES 3