Learn how to sign in and access your portal programmatically using an access token.
Prerequisites
You need the following for this tutorial:
- Account: An ArcGIS Location Platform, ArcGIS Online, or ArcGIS Enterprise account.
- Authentication: A basic understanding of API key authentication or User authentication.
Steps
Get the portal URL
To access a portal, you need an ArcGIS account which is associated with an organization that allows you to store and manage your content.
- In a web browser, sign in to your portal with your ArcGIS account.
- Identify the portal URL from the navigation bar. The base URL should be one of the following:
- ArcGIS Location Platform:
https
://www.arcgis.com/sharing/rest - ArcGIS Online:
https
://www.arcgis.com/sharing/rest - ArcGIS Enterprise:
https
://{machine.domain.com}/{webadaptor}/rest
- ArcGIS Location Platform:
- Copy the URL and store it in a safe location. You will need it in a later step.
Implement authentication
You need an access token with the correct privileges for in this tutorial.
-
Go to the Create an API key tutorial and create an API key with the following privilege(s):
-
Privileges
- Admin privileges > Content > View all
-
Set up environment
- In a different window, launch Postman and create a blank request.
Perform a self
call
- Set the request type to
POST
. - Paste your portal URL and append
/self
at the end. - Set the
f
parameter tojson
in the parameter list. - Set the
token
parameter to your access token in the parameter list. - Run the request.
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded
&f=json
&token=<YOUR_ACCESS_TOKEN>
View the results
The output of your self
call should look something like this, but with information about your portal:
{
"2DStylesGroupQuery": "title:\"Esri 2D Styles\" AND owner:esri_en",
"3DBasemapGalleryGroupQuery": "title:\"ArcGIS Online 3D Basemaps\" AND owner:esri_en",
"access": "public",
"allSSL": true,
"allowedRedirectUris": [],
"analysisLayersGroupQuery": "title:\"Living Atlas Analysis Layers\" AND owner:esri",
"authorizedCrossOriginDomains": [],
"availableCredits": 5.0018196E7,
"basemapGalleryGroupQuery": "title:\"United States Basemaps\" AND owner:Esri_cy_US",
"canListApps": false,
"canListConsultingServices": false,
What's next
Copy a hosted layer item
Use the portal service to copy a hosted layer item in your portal.
Set sharing level for an item
Use the portal service to set the sharing level for an item in your portal.
Create a new group and add members
Use the portal service to create a new group and add members in your portal.