once we generate an access token using client credentials grant type (In post verb) something like this
after this in Get verb whenever client hit on another api then user got response and internally dynamically allocated to access token in header
for this this i created a proxy called as PC-Demo-1 with the verify access token(OAuth2.0) and in this proxy i passed basepath https://mocktarget.apigee.net/json
and in another api proxy i set as no target point and inside this i generated access token
and now i want i don't type access token i want whenever i hit on pc-demo-2-oauth2 api with grant type etc . and its verify and then if i hit on pc-demo-1 i got response
Answer by Priyadarshi Ajitav Jena · Feb 17 at 04:22 PM
Ok, it seems you want to automate in postman.
What you can do is select one environment.
In the first api request in postman, under tests write
var data = JSON.parse(responseBody); postman.setEnvironmentVariable("access_token_ad", data.access_token);
this will set the access_token's value in body to environment.
In the second api
in the Authorization value place write
Basic {{access_token_ad}}
this will automatically take the value. You need not to enter manually in second api request in postman.
sir but i want like my access token is stored in a variable after this somehow in first api's header is attached with access token in header may be we can do this thing using assign message policy and Extract variable
That is a bad practice. Oauth 2.0 is know for its two legged and 3 legged nature.
If still you want then just store in cache of your app and use until it expires. This is something we have implemented.
If you want to set inside proxy, I would suggest to store in Apigee cache and use.
But if you want to do a service callout and get the token from its response and send to the backend it can be done but not a a good practice.
"But if you want to do a service callout and get the token from its response and send to the backend it can be done but not a a good practice." exactly i want this i knew it's bad practice i am exploring thing how it is work so can you suggest me how can i do this
could you please drop your mail-id
Getting fault string as "Failed to execute JavaCallout. null" while executing java callout 5 Answers
How to support target pre and post flow in shared-flow in apigee ? 1 Answer
how to display developer details when ever we hit on api it should be display in body 1 Answer
how to validate if header attributes has spaces ex- "Cache-Control" and : 1 Answer