Trying to get list of products associated to a apikey

We have a requirement to get list of api products associated to api keys.

We found that app flow variables https://docs.apigee.com/api-platform/reference/policies/verify-api-key-policy i.e. verifyapikey.{policy_name}.app.apiproducts should return the result.

When we try to get the value in javascript it returns [Ljava.lang.String;@7a19405a.

We were able to get the value in a java callout , but somehow a it doesn't work in javascript

Is there a way to can get the array returned in javascript rather than relying solely on java callout?

0 5 615
5 REPLIES 5

@Dino-at-Google ,@Dino can you please check this issue.

Mmmm I don't know of a way to get access to that information other than using a Java callout.

That's not very friendly. sorry!

When you reference that variable in a JS callout, it will always be coerced to a string. And the representation is always something like [Ljava.lang.String;@7a19405a.

I can iterate through verifyapikey.{policy_name}.app.apiproducts to get each api product name.. But the name looks like '<Product Name> [Ljava.lang.String;@7a19405'. Can we rely on that ?

That [Ljava.lang.String;@7a19405 thing is a default representation generated by the Java language runtime, it's not meaningful for your purposes unfortunately.

Can you show me your iteration code?

Not applicable

You can try below management api call to get the products registered with a key.

curl -X GET "https://api.enterprise.apigee.com/v1/organizations/org_name/developers/developer_email_or_id/apps/app_name/keys/consumer_key/apiproducts"

Else you can use AccessEntity policy to get the developer app information for the key and use extract varibale policy to extract the products registered with that.