How can i list apiproducts from an access_token?

Using the policy "Verify Api Key", several variables are populated, according to the doc here: http://apigee.com/docs/api-services/reference/verify-api-key-policy

I want to examine the apiproducts, which is contained in "verifyapikey.Verify-API-Key.app.apiproducts". But when i print the value, it is "[Ljava.lang.String;@5e0ef832"

An App can have multiple products, how can i list all products from that app?

Solved Solved
1 8 694
1 ACCEPTED SOLUTION

Not applicable

@kiquetal_edge

You can use the Access Entity policy to extract the app attributes, which should also include the API Product list, as an XML formatted variable.

http://apigee.com/docs/api-services/reference/access-entity-policy

I have attached the API proxy with the access entity policy. After this policy got executed, I see the following variable.

Variable Name: AccessEntity.ChildNodes.Access-Entity-1.App.Credentials.Credential.ApiProducts Variable Value:

<ApiProducts>
  <ApiProduct>
    <Name>PremiumWeatherAPI</Name>
    <Status>approved</Status>
  </ApiProduct>
</ApiProducts>

Here are the contents of the policy

<AccessEntity name="Access-Entity-1">
    <DisplayName>Access Entity 1</DisplayName>
    <Properties/>
    <EntityIdentifier ref="apigee.client_id" type="consumerkey"></EntityIdentifier>
    <EntityType value="app"></EntityType>
</AccessEntity>


Let me know if this is what you are looking for.

View solution in original post

8 REPLIES 8

adas
New Member

The access_token response itself contains the apiproducts list, here's a sample access token response for the generate access token policy:

{
  "issued_at" : "1432657201204",
  "scope" : "",
  "application_name" : "xxxx-xxx-xxxxxx",
  "refresh_token_issued_at" : "1432657201204",
  "status" : "approved",
  "refresh_token_status" : "approved",
  "api_product_list" : "[payment]",
  "expires_in" : "9",
  "developer.email" : "xxxxx-121@apigee.com",
  "token_type" : "BearerToken",
  "refresh_token" : "lMRAQ0uvoGkcTon3gxEGDbxDx",
  "client_id" : "e6DU6sZMe0Q5yCtLz2AlUvSf",
  "access_token" : "KR7ByH0GU5Gl4kTby5SQ",
  "organization_name" : "apigee-xxx",
  "refresh_token_expires_in" : "0",
  "refresh_count" : "0"
} 

Similarly, you have the GetOAuthV2Info, which can get all the access token attributes given the access token. You can find more information and official docs here: http://apigee.com/docs/api-services/content/oauth-home

I know the response from generateAccessToken..., but i cannot access to the property "api_products_list"; when i use the getOauthv2 policy only data from the first apiproducts is populated.

Thanks,but my problem is how can i retrieve inside another apiproxy, the policies don't work 😞

Not applicable

@kiquetal_edge

You can use the Access Entity policy to extract the app attributes, which should also include the API Product list, as an XML formatted variable.

http://apigee.com/docs/api-services/reference/access-entity-policy

I have attached the API proxy with the access entity policy. After this policy got executed, I see the following variable.

Variable Name: AccessEntity.ChildNodes.Access-Entity-1.App.Credentials.Credential.ApiProducts Variable Value:

<ApiProducts>
  <ApiProduct>
    <Name>PremiumWeatherAPI</Name>
    <Status>approved</Status>
  </ApiProduct>
</ApiProducts>

Here are the contents of the policy

<AccessEntity name="Access-Entity-1">
    <DisplayName>Access Entity 1</DisplayName>
    <Properties/>
    <EntityIdentifier ref="apigee.client_id" type="consumerkey"></EntityIdentifier>
    <EntityType value="app"></EntityType>
</AccessEntity>


Let me know if this is what you are looking for.

@kiquetal_edge you can try using the Access Entity policy to query the "app" entity-type using the client_id from the access_token. This should give you all the details of the app which could contain the list of products that the app has registered for.

Would this work for you?

Reference : Apigee Docs

Not applicable

Your accessing the right variable but your problem is how do i deal with this array of strings. There is another post that explains how to deal with this by converting the data type in javascript and parsing out all of the values see the answer to this question as an example.

http://community.apigee.com/questions/1858/why-am-i-getting-a-js-exception-when-accessing-one.html

I will check this, thanks!

FYI: The value "[Ljava.lang.String;@5e0ef832" is just a Java representation of an array of String. You didn't say how you want to "get" the list of API products... how are you getting them? From within a Java callout?