Retrieve display name using Generate OAuth2.2 token policy/Get OAuth2.0 info policy

Not applicable

Hello,

I just wanted to know if there is a variable to access in order to retrieve the display name of an app instead of his real name (ie {apigee.developer.app.name})

If there any way to do that could you tell me how ?

Thanks and greetings,

Xavier


Solved Solved
1 7 411
1 ACCEPTED SOLUTION

I'm not clear if you want this to happen during VERIFICATION of a token, or during GENERATION of a token? But in either case, that variable is not populated automatically.

To get it, you must have the client_id (aka consumer_id). Then, use an AccessEntity policy , followed by an ExtractVariables policy.

Supposing the client_id is stored in a context variable named "inbound_client_id", the AccessEntity should look like:

<AccessEntity name='AE-App'>
  <EntityType value='app' />
  <EntityIdentifier ref="inbound_client_id" type="consumerkey"/>>
  <!--
      The XML result is stored in a variable:  AccessEntity.AE-App
      Next step is to use ExtractVariables to get a value from that entity.
  -->
</AccessEntity>

The ExtractVariables should be something like this:

<ExtractVariables name='Extract-AppDisplayName'>
  <Source>AccessEntity.AE-App</Source>
  <XMLPayload>
    <Variable name='extracted_app_display_name' type='string'>
      <XPath>/App/Attributes/Attribute[Name='DisplayName']/Value/text()</XPath>
    </Variable>
  </XMLPayload>
</ExtractVariables>

Then, you will have a variable in context called "extracted_app_display_name" .

View solution in original post

7 REPLIES 7

I'm not clear if you want this to happen during VERIFICATION of a token, or during GENERATION of a token? But in either case, that variable is not populated automatically.

To get it, you must have the client_id (aka consumer_id). Then, use an AccessEntity policy , followed by an ExtractVariables policy.

Supposing the client_id is stored in a context variable named "inbound_client_id", the AccessEntity should look like:

<AccessEntity name='AE-App'>
  <EntityType value='app' />
  <EntityIdentifier ref="inbound_client_id" type="consumerkey"/>>
  <!--
      The XML result is stored in a variable:  AccessEntity.AE-App
      Next step is to use ExtractVariables to get a value from that entity.
  -->
</AccessEntity>

The ExtractVariables should be something like this:

<ExtractVariables name='Extract-AppDisplayName'>
  <Source>AccessEntity.AE-App</Source>
  <XMLPayload>
    <Variable name='extracted_app_display_name' type='string'>
      <XPath>/App/Attributes/Attribute[Name='DisplayName']/Value/text()</XPath>
    </Variable>
  </XMLPayload>
</ExtractVariables>

Then, you will have a variable in context called "extracted_app_display_name" .

Hi Dino, thanks for the quick response, I will try your solution.

Just to be clear, it is not during VERIFICATION or GENERATION of a token but after, when I generate a custom response to the end user, I want to display the display name instead of the name.

Greetings

Hi Dino, I tested your solution and it works. Thanks for all,

Grettings, Xavier

This is a great solution, I would note that you should always wrap this sequence of policy with a lookup / populate cache policy, access_entity does a stateful lookup and cause an increase in latency and can have an overall performance impact on the api's that use it

Gooooood point!

This is a break down of response times the first being un-cached, the second three tier-2 (persistent) cached responses and the final two are cached from tier 1(in-memory) with no target

5938-screen-shot-2017-11-16-at-100336-am.png

For those interested in the seeing the proxy used to demonstrate the ability to retrieve this info along with caching -- test-get-appdisplayname-rev1-2017-11-16.zip