Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How can we pass dynamic access token to every API request through authentication?

Not applicable

I am new to this apigee so I need your suggestions to make an API/webservice. Please help me on this. My requirement is that, I need to pass an access token value as header parameter to all my API requests.Prior to that I need to make an authentication call using some credentials (username,password,client id etc).As a result of this authentication call I will get an auth-token (this value is dynamic). I need to pass this auth-token value to all the upcoming API call as a header parameter.How can I achieve this using APIGEE.Please someone help me with some sample codes.Any help is appreciated.

Solved Solved
0 14 7,430
1 ACCEPTED SOLUTION

Hi @Geo V L, this can be achieved using Service Callout(SC), Extract Variable(EV) & Assign Message(AM) policies.

We can add them on the Proxyendpoint Preflow.

  1. First, we will be using an SC to call the authentication service(3rd party HTTP/s Service), you can hardcode, username, password, client id details here or get them dynamically from the request.
  2. If these values are coming from the request, then use an EV policy before SC to extract out these details & use them in SC.
  3. This SC will make a call to authentication service with the details & give you an auth-token in response.
  4. Use another EV to extract the required auth-token.
  5. Then use an AM policy to Set an Header with the extracted token from previous step.

I dont have sample code. Why don't you start working on a proxy by following above steps & then if you are stuck, post here.

View solution in original post

14 REPLIES 14
Top Solution Authors