Oauth grant_type error, postman

gungc
Participant I

Im trying to follow this tutorial on putting oauth 2 into an endpoint.

When I try to generate the token in Post man, I get this error:

{"ErrorCode" : "invalid_request", "Error" :"Required param : grant_type"}

if I add the grant_type param into the post request, I get the same error. Here is my policy configuration:

<OAuthV2 name="OA-GenerateAccess"> 
  <Operation>GenerateAccessToken</Operation>
  <ExpiresIn>1800000</ExpiresIn>
  <SupportedGrantTypes>
    <GrantType>client_credentials</GrantType>
  </SupportedGrantTypes>
  <GenerateResponse enabled="true"/>
</OAuthV2>

Appreciate any help. Thanks

Reference similarity: https://community.apigee.com/questions/58181/400-required-param-grant-type-when-issuing-oauth2.html

Solved Solved
1 3 995
1 ACCEPTED SOLUTION

jyothikiranr
Participant IV

@Chris Gungaloo

Adding GrantType should work. In the following modification, I added form param instead if the default query param (which is missing in your policy). If you want to test with query param, change request.formparam.grant_type to request.queryparam.grant_type Let us know if that helps.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OAuthV2 async="false" continueOnError="false" enabled="true" name="OA-GenerateAccess">
<DisplayName>OA-GenerateAccess</DisplayName>
<Operation>GenerateAccessToken</Operation>
<ExpiresIn>1800000</ExpiresIn>
<SupportedGrantTypes>
<GrantType>client_credentials</GrantType>
</SupportedGrantTypes>
<GrantType>request.formparam.grant_type</GrantType>
<GenerateResponse enabled="true"/>
</OAuthV2>

View solution in original post

3 REPLIES 3

gungc
Participant I

jyothikiranr
Participant IV

@Chris Gungaloo

Adding GrantType should work. In the following modification, I added form param instead if the default query param (which is missing in your policy). If you want to test with query param, change request.formparam.grant_type to request.queryparam.grant_type Let us know if that helps.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OAuthV2 async="false" continueOnError="false" enabled="true" name="OA-GenerateAccess">
<DisplayName>OA-GenerateAccess</DisplayName>
<Operation>GenerateAccessToken</Operation>
<ExpiresIn>1800000</ExpiresIn>
<SupportedGrantTypes>
<GrantType>client_credentials</GrantType>
</SupportedGrantTypes>
<GrantType>request.formparam.grant_type</GrantType>
<GenerateResponse enabled="true"/>
</OAuthV2>

It seems to work when I add request.queryparam.grant_type:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<OAuthV2 async="false" continueOnError="false" enabled="true" name="OA-GenerateAccess">

<DisplayName>OA-GenerateAccess</DisplayName> <Operation>GenerateAccessToken</Operation>

<ExpiresIn>1800000</ExpiresIn>

<SupportedGrantTypes>

<GrantType>client_credentials</GrantType>

</SupportedGrantTypes> <GrantType>request.queryparam.grant_type</GrantType> <GenerateResponse enabled="true"/>

</OAuthV2>

Not sure why it doesn't work when I specify it as a grant type in the proxy.

Thank you.