I want to apply ropc grant type in apigee and use token from backend as external token to oauth2 policy ,but i do not know how generated token from apigee will work with backend
I have login api that take email and password and response is token
i have two scenarios
1- first to use serviceCallOut and call this api direct and return the token.
ok. No problem. The ServiceCallout equivalent of your curl command is
<ServiceCallout continueOnError='true' name='SC-Login'>
<Request variable='outboundRequest'>
<Set>
<Payload contentType='application/json'>{
"email":"test@nbg",
"password": "Secret123"
}</Payload>
<Verb>POST</Verb>
</Set>
</Request>
<Response>loginResponse</Response>
<HTTPTargetConnection>
<SSLInfo>
<Enabled>true</Enabled>
<IgnoreValidationErrors>true</IgnoreValidationErrors>
</SSLInfo>
<Properties>
<Property name='success.codes'>2xx, 4xx, 5xx</Property>
</Properties>
<URL>https://www.sit.com:9006/api/v4/auth/login</URL>
</HTTPTargetConnection>
</ServiceCallout>
The result of that call will be placed in a variable of Message type, named loginResponse
. The JSON content will be in loginResponse.content
. You can use an ExtractVariables policy to extract the token, if you want to grab it or store it.
2- second to apply oauth2 policy with ropc grant type (return opaque token) and also make service callout to request login api and return the token then cache the opaque token as a key and token return from backend as a value then return the generated access token from oauth as opaque token
OK. I don't understand any of that. I can read the words but they're not making sense to me. I'm not sure what you want. But if you want to cache things, use the cche policy. If you want an opaque OAuth token, use the OAuthV2 policy with Operation = GenerateAccessToken. I think you somehow want to combine these things, but I tried a couple times and I can't understand your goal. Sorry about that.