Select to view content in your preferred language

Accessing ArcGIS Server Usage Reports with Developer Credentials

140
0
2 weeks ago
BenSaunders1
Regular Contributor

So we'd like to set up a script that accesses ArcGIS Server usage reports. However we're having problems accessing them with Developer Credentials - i.e. client_id and client_secret. We have tried the following workflows:

We set up developer credentials in Portal with the correct admin privileges (in fact for testing, we've enabled  all 33 admin privileges).

We then get a token from Portal:

POST https://myportal.example.com/arcgis/sharing/rest/oauth2/token
client_id=<client_id>
client_secret=<client_secret>
grant_type=client_crednetials
f=json

 We then use that token to get a list of usage reports:

POST https://myserver.example.com:6443/arcgis/admin/usagereports
token=<token>
f=json

 But it returns:

{
    "status": "error",
    "messages": [
        "Unable to reach the Federated Server Administrator Directory. Ensure your administrative privileges are sufficient to reach the Federated Server Administrator Directory and try again."
    ],
    "code": 403
}

 

A second workflow we tried was to get the token from Portal just like before:

POST https://myportal.example.com/arcgis/sharing/rest/oauth2/token
client_id=<client_id>
client_secret=<client_secret>
grant_type=client_crednetials
f=json

Exchange it for a server token:

POST https://myportal.example.com/arcgis/sharing/rest/generateToken
token=<token>
serverUrl=https://myserver.example.com:6443/arcgis
f=json

And then try to access the usage reports:

POST https://myserver.example.com:6443/arcgis/admin/usagereports
token=<server token>
f=json

But we get the same exact error.

We are able to view, create, and run the usage reports through the REST API if we log in directly with the account that owns the developer credentials rather than use the client_id and client_secret, so we know they work.

Our overall goal is to use a script that takes advantage of the developer credentials rather than bundling the username and password of an admin account. So any insight anyone can provide would be greatly appreciated - thanks!

Ben

0 Kudos
0 Replies