Search Engine: Elastic

Article ID: 120089, created on Feb 12, 2014, last review on Jul 14, 2018

  • Applies to:
  • APS


I need to get the token for customer or provider account to query APS controller from a REST client. How can I get one?


The easiest way would be to add a line to your custom UI:

console.log("Token: " + aps.context.token);

If you add this to Provider's panel, you will get provider's token. From customer's panel UI you will get a token for currently logged in customer.

You can also check any requests sent using 'aps/xhr' in debugger (network tab in Firebug or Chrome Dev tools). Such requests have 'APS-Token' header containing the token set.

Third way is to use pem.APS.getAccountToken API method call. This API method is described in Operations Automation documentation.

There is a script attached to this document that makes use of this API method.

Script usage information:

Usage: [options]

  -h, --help            show this help message and exit
  -e ENV_NAME, --environment=ENV_NAME
                        environment name, i.e. ""
  -c CUSTOMER_ID, --customer=CUSTOMER_ID
                        ID of customer account, 1 for provider
  -s SUB_ID, --subscription=SUB_ID
                        ID of customer's subscription

You can copy it to your Operations Automation management node and run there:

[root@mn ~]# ./
Querying POA MN at localhost. Token for customer #1, subscription #0:

Script defaults to querying 'localhost' for customer #1 (provider) with no subscription context provided (subscription #0).

You can also run the script from any other machine, including Windows machines (if you have python installed), and supply the hostname of your Operations Automation management node for the script (OpenAPI calls to Operations Automation must be allowed from the machine you run the script on):

PS C:\Users\mbelov\TEMP> python .\ -e -c 4 -s 14
Querying POA MN at Token for customer #4, subscription #14:

Keep in mind that these tokens expire in 15-20 minutes and you will have to obtain ones once the one you use expires.


Email subscription for changes to this article
Save as PDF