Access developer email in Javascript

Hi, I am using AccessEntity policy to get developer email :

 

<AccessEntity name="AccessEntity">
<EntityType value="developer"/>
<EntityIdentifier ref="developer.email" type="developeremail"/>
</AccessEntity>

 


I want to access this variable in my javascript file at `resource/jsc` like this:

 

var email = context.getVariable("developer.email")​

 

How can I do that? Help please ? @dchiesa1 @DChiesa @anilsr

Solved Solved
1 2 129
1 ACCEPTED SOLUTION

I think your understanding of AccessEntity is not quite right. The policy configuration you are using will retrieve an entire Developer entity, based on the developer email. In other words, the developer email must be an INPUT to the AccessEntity policy you have.

But maybe there is a simpler way of getting what you want. If you have a VerifyAPIKey policy or an OAuthV2/VerifyAccessToken policy, then the context variable apigee.developer.email gets populated implicitly by the policy when it succeeds. You can then access it in JavaScript with context.getVariable().  You don't need AccessEntity in this case. Does this satisfy your requirement?

View solution in original post

2 REPLIES 2

I think your understanding of AccessEntity is not quite right. The policy configuration you are using will retrieve an entire Developer entity, based on the developer email. In other words, the developer email must be an INPUT to the AccessEntity policy you have.

But maybe there is a simpler way of getting what you want. If you have a VerifyAPIKey policy or an OAuthV2/VerifyAccessToken policy, then the context variable apigee.developer.email gets populated implicitly by the policy when it succeeds. You can then access it in JavaScript with context.getVariable().  You don't need AccessEntity in this case. Does this satisfy your requirement?

Yes, this helps! Thank you for correcting me. 🙂