Get OAuth V2 Info policy not working

Not applicable
<PreFlow name="PreFlow">
        <Request>
            <Step>
                <Name>OAuth-v20-1</Name>
            </Step>
            <Step>
                <Name>Get-OAuth-v20-Info-1</Name>
            </Step>
        </Request>
        <Response/>
    </PreFlow>

OAuthV2:

<OAuthV2 async="false" continueOnError="false" enabled="true" name="OAuth-v20-1">
    <DisplayName>OAuth v2.0-1</DisplayName>
    <Properties/>
    <Attributes/>
    <ExternalAuthorization>false</ExternalAuthorization>
    <Operation>VerifyAccessToken</Operation>
    <SupportedGrantTypes/>
    <GenerateResponse enabled="true"/>
    <AccessTokenPrefix/>
</OAuthV2>

GetOAuthV2Info:

<GetOAuthV2Info async="false" continueOnError="false" enabled="true" name="Get-OAuth-v20-Info-1">
    <DisplayName>Get OAuth v2.0 Info-1</DisplayName>
    <AccessToken ref="request.queryparam.access_token"/>
</GetOAuthV2Info>

I am trying to retrieve the attributes for a access_token using the GetOAuthV2Info policy. But response returning the error 401 unauthorized.

Why am I getting this error?

0 6 337
6 REPLIES 6

@van long , Welcome to Apigee Community.

When you do VerifyAccessToken , Token attributes are available as flow variables. You don't need to specifically use GetOAuthv2Info policy. Based on above error looks like token is invalid one. Can you please let us know how are you generating Access token ? Which OAuth grant flow you are using to generate same ?

The access token is definitely valid.

I'm learning Apigee.

The OAuthV2 policy is configured:

<OAuthV2 async="false" continueOnError="false" enabled="true" name="OAuth-v20-1">
    <DisplayName>OAuth v2.0-1</DisplayName>
    <Properties/>
    <Attributes/>
    <ExternalAuthorization>false</ExternalAuthorization>
    <Operation>VerifyAccessToken</Operation>
    <SupportedGrantTypes/>
    <GenerateResponse enabled="true"/>
    <AccessToken>request.queryparam.access_token</AccessToken>
</OAuthV2>

If I try to pass a valid token via a query parameter:

http://{host}/endpoint?access_token=iloveapigee

I get a response OK.

Now, I continue to learn about Set OAuth v2.0 Info.

Thanks in advance! ありがとうございます。My English was clumsy.

Not applicable

I'm learning Apigee.

Now, I continue to learn about Set OAuth v2.0 Info.

Please, give me examples of Set OAuth v2.

Thanks in advance! ありがとうございます。My English was clumsy.

@van long ,

Is your original question (retrieve the attributes for a access_token using the GetOAuthV2Info policy) above answered ? Do you still see issue with GetOAuthV2Info ?

GetOAuthV2Info: I get a response OK. Image attached a below.

Now, I continue to learn about Set OAuth v2.0 Info. However, I don't know about this policy. I hope this example.

Thanks in advance!

3520-ques-2.png

@van long , You can find more about setOAuthV2Info policy here in our docs.