Hello Arnnab,
In response flow callout a javascript policy to fetch the location header ( context.getVariable("response.header.location")) and write your logic to fetch the authorization code from the header.
Or follow a neat and clean way, by setting GenerateResponse to false and poplulating the code as flow variable. Following is mentioned in the docs (http://docs.apigee.com/api-services/content/access-tokens) :
With enabled, the policy returns ?code query parameter to the redirect_uri (Callback URI) location with the authorization code attached. It is sent via a 302 browser redirect with the URL in the Location header of the response. For example: ?code=123456.
If is set to false, the policy does not return a response. Instead, it populates the following set of flow variables with data pertaining to the authorization code.
Let me know if it is still not working for you.
Thanks
I tried using the js to print the print(context.getVariable("request.header.location")); after the generateAuthorization and it is returning empty. Any thoughts?
hey @pswam, instead of fetching it from request get it from the response. Please try context.getVariable("response.header.location")
variable identifier was wrong, I was able to get it once I fixed the variable
@aagrawal @aarnab
I am not sure if you could get the above working. I am working on the same scenario. If the GenerateResponse is set to false, I do not see the flow variable being populated with the value. Am i missing something here? It does not show the variable when I turn on the tracing in Edge.
Thanks
Yes I got it working. If you can tell me the scenario like policies being used , I can help you with the steps to extract the auth code.