is there a flow variable for application name which can be used in javascript policy ?

Not applicable

I have configured multiple apps and I want to know that which app is sending me request. Is there a way to do that ?

0 17 4,036
17 REPLIES 17

Hi @utsav kansara

Assuming you are using a Verify Api Key policy. You can use "apigee.developer.app.name" or "verifyapikey.{verify-api-key-policy}.developer.app.name" to get the app name. You can see the list of variables in your trace session under this policy

You can use context.getVariable(name) within your Javascript appropriately.

More info here

Please click "accept" if you accept the answer.

You can take a look at Access Entity policy too

well, thanks for your answer. I am using OAuth V2.0 policy not Verify Api Key policy. So This variables will not be useful for me.

I wrote a sample policy that uses OAuth policy - VerifyAccessToken operation. After the execution, I have a simple Javascript policy that prints "developer.app.name". App name printed as expected. Isn't this working for you ?

Hi @utsav kansara - Is this resolved ?

adas
New Member
@utsav kansara

Following are the list of flow variables that get populated when the verifyapikey policy gets executed successfully:

verifyapikey.VerifyAPIKey.apiproduct.name     
verifyapikey.VerifyAPIKey.client_id     
verifyapikey.VerifyAPIKey.client_secret     
verifyapikey.VerifyAPIKey.developer.app.id      
verifyapikey.VerifyAPIKey.developer.app.name      
verifyapikey.VerifyAPIKey.developer.email     
verifyapikey.VerifyAPIKey.developer.id      
verifyapikey.VerifyAPIKey.DisplayName     
verifyapikey.VerifyAPIKey.expires_in      
verifyapikey.VerifyAPIKey.failed      
verifyapikey.VerifyAPIKey.issued_at     
verifyapikey.VerifyAPIKey.Notes     
verifyapikey.VerifyAPIKey.redirection_uris      
verifyapikey.VerifyAPIKey.status 

I hope this list helps you.

well, thanks for your answer. I am using OAuth V2.0 policy not Verify Api Key policy. So This variables will not be useful for me.

Please refer to the doc link here for the flow variables in case you are using OAuth v2.0 policies. Refer to the section called "Flow Variables"

@arghya das Thanks a lot !!! That will help me.

Hi @arghya das Does this list above work with OAuth Access Token validation policy instead of verifying api key? Do you know an easy way to retrieve developer custom attribute using a flow variable?

Thanks,

Krish

Yes @Krish - Please refer to this link

You can access the custom attributes as flow variables by using

accesstoken.{custom_attribute}

@Sai Saran Vaidyanathan

It didn't work.

Here is my Javascript added after the Validation access token policy in proxy preflow.

print("name==>"+context.getVariable("accesstoken.spikeLimit")); print("Limit==>"+context.getVariable("APICommon_oAuthV2_ValidateAccessToken.spikeLimit"));

Both printed as null.

Here is my Validate access token policy.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <OAuthV2 async="false" continueOnError="false" enabled="true" name="APICommon_oAuthV2_ValidateAccessToken"> <DisplayName>APICommon_oAuthV2_ValidateAccessToken</DisplayName> <Operation>VerifyAccessToken</Operation> </OAuthV2>

Thanks,

Krish

@Krish

Try this - The above is true if you are setting the attributes using the <Attributes> tag in the GenerateAccessToken policy in your OAuth proxy. If you are trying to get the custom attributes from your Product or Developer App configurations, then the flow variables are

apiproduct.{custom_attribute}
app.{custom_attributes}

On the trace tool, click the APICommon_oAuthV2_ValidateAccessToken to get the variables and you can use that

5008-screen-shot-2017-06-05-at-101843-am.png

You are amazing. Thank you @Sai Saran Vaidyanathan !

Happy to help !!! 🙂

Hi is there way to get App name when no verify API key policy is used. Instead verifyJWT policy is used. I believe variable listed allow will work only when verify API policy is in use. 

I believe variable listed allow will work only when verify API policy is in use.

correct.


@SamadhanGudekar wrote:

is there way to get App name when no verify API key policy is used.


No.  If you use VerifyJWT, then, to get the registered Apigee App, you must follow it by calling VerifyAPIKey. Usually you would specify as the APIKey, a claim (like clientid) that is present in the JWT. 

FYI: you are replying to a thread which is 6 years old. Sometimes new questions posted in comments to old threads are completely missed, ignored!  I suggest that next time, you post your own question in a new thread.