Hello,
I’m a newbie to Apigee, so any suggestion will be appreciated.
I need to generate an access token after the 3rd party API returns 200 status code,
So i made a simple approach like doing a service callout API that takes a username and password and later after getting the “success” response. Then i created a request payload using Assign Message with my client ID and secret and lastly i used Generate Access token policy.
But i dont know, it throws me back 401.
Here, my service callout action shows up to be “PAUSE” while tracing.
<!-- Token Gen -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OAuthV2 name="GenerateAccessToken">
<DisplayName>OA-GenerateAccessToken Password</DisplayName>
<Operation>GenerateAccessToken</Operation>
<!--<ExternalAccessToken>apigee.access_token</ExternalAccessToken>-->
<!-- This is in millseconds, so expire in an hour -->
<ExpiresIn>36000000</ExpiresIn>
<SupportedGrantTypes>
<GrantType>password</GrantType>
</SupportedGrantTypes>
<GrantType>the.grant_type</GrantType>
<UserName>token.request.username</UserName>
<PassWord>token.request.password</PassWord>
<GenerateResponse enabled="true"/>
<GenerateErrorResponse enabled="true"/>
</OAuthV2>
<!-- Assign Message Payload for token generation -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-generate-token-request">
<DisplayName>AM-generate token request</DisplayName>
<Set>
<Headers>
<Header name="Content-Type">application/json</Header>
<Header name="Authorization">Basic REUwR1VWb0ttR045OHFic282ZEdoaDJ3QXVDQTFvVGc6MTg2Y3lTVU9TOFZYTUVmMQ==</Header>
</Headers>
<QueryParams>
<QueryParam name="username">XXXXXXoKmGN98qbso6dGhh2wAuCA1oTg</QueryParam>
</QueryParams>
<QueryParams>
<QueryParam name="password">XXXXXXUOS8VXMEf1</QueryParam>
</QueryParams>
<Verb>POST</Verb>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="true" transport="https" type="request">token.request</AssignTo>
</AssignMessage>
<!-- Service Callout -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-Edge-Market-API">
<DisplayName>SC Edge Market API</DisplayName>
<Properties/>
<Request clearPayload="false" variable="authenticate.request">
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</Request>
<Response>authenticate.response</Response>
<HTTPTargetConnection>
<Properties/>
<URL>https://edgemarket-prod.apigee.net/v1/users/authenticate</URL>
</HTTPTargetConnection>
</ServiceCallout>