Tutorial: Create OAuth credentials for app authentication

Learn how to create OAuth credentials to support app authentication.

The developer credentials creation interface in a portal.
The developer credentials creation interface in a portal

OAuth credentials are an item required to implement app authentication. They contain client_id and client_secret parameters that are used to implement an OAuth 2.0 client credentials flow. The item page of OAuth credentials allows you to manage settings related to app authentication, including the authorized privileges of an application.

This tutorial shows you how to create OAuth credentials for use in app authentication and do the following:

  • Configure privileges to allow your application to access ArcGIS services, content, and functionality.
  • Set authorized referrer URLs.
  • Manage settings of the OAuth credentials and monitor usage using its item page.

Prerequisites

Steps

Sign in to your portal

You use your portal to create and manage items, including OAuth credentials.

  1. Access your portal by navigating to ArcGIS.com or the URL of your ArcGIS Enterprise portal instance.

  2. Sign in with your ArcGIS account.

Create a new item

  1. In your portal, click Content > My content > New item.

    New item button
  2. Click Developer credentials > OAuth credentials and click Next.

    OAuth credentials

Set referrer URLs

You can set referrer URLs on OAuth credentials that restrict the credentials to only be usable from authorized domains. This is highly recommended for security purposes.

  1. In the next window, scroll down to Referrer URLs.

  2. Set the Referrers field to the web domains you would like to restrict the access token to. To learn more about referrers, go to OAuth credentials (for app authentication).

    Referrer selector
  3. Under Application environment, select the type of environment your application will run in. This will affect when the OAuth credentials appear in portal search results.

    Application environment
  4. Click Next.

Select privileges

You use developer credentials to configure the privileges of access tokens. For an access token to work in your application, it needs to have the correct privileges to access the content and services your app is using. Select the privileges you require to apply them to your API key access token.

  1. In the Create developer credentials > Privileges window, browse the available privileges.

    Privileges window
  2. Browse the table below to view the available privileges, privilege strings, and descriptions based on your account type:

    ArcGIS Location Platform accountsArcGIS Online accountsArcGIS Enterprise accounts
    CategoryLabelPrivilege stringDescription
    BasemapsBasemap styles servicepremium:user:basemapsAllow application to access the basemap styles service.
    Data enrichmentGeoEnrichment servicepremium:user:geoenrichmentAllow application to access the GeoEnrichment service. Learn more
    GeocodingGeocode (stored)premium:user:geocode:storedAllow application to access the geocoding service and perform stored geocodes. Learn more
    GeocodingGeocode (not stored)premium:user:geocode:temporaryAllow application to access the geocoding service and perform geocodes that are not stored. Learn more
    PlacesPlace findingpremium:user:placesAllow application to access the places service. Learn more
    RoutingRoutingpremium:user:networkanalysis:routingAllow application to access the routing service and perform standard routing operations. Learn more
    RoutingClosest facilitypremium:user:networkanalysis:closestfacilityAllow application to access the routing service and perform closest facility routing operations. Learn more
    RoutingLocation allocationpremium:user:networkanalysis:locationallocationAllow application to access the routing service and perform location allocation operations. Learn more
    RoutingOptimized routingpremium:user:networkanalysis:optimizedroutingAllow application to access the routing service and perform optimized routing operations. Learn more
    RoutingOrigin/destination cost matrixpremium:user:networkanalysis:origindestinationcostmatrixAllow application to access the routing service and generate travel cost matrices. Learn more
    RoutingService areapremium:user:networkanalysis:serviceareaAllow application to access the routing service and generate service areas. Learn more
    RoutingMulti-vehicle routingpremium:user:networkanalysis:vehicleroutingAllow application to access the routing service and perform fleet routing operations. Learn more
    RoutingLast milepremium:user:networkanalysis:lastmiledeliveryAllow application to access the routing service and perform routing operations for last mile delivery. Learn more
    CategoryLabelPrivilege stringDescription
    BasemapsBasemap styles servicepremium:user:basemapsAllow application to access the basemap styles service.
    Data enrichmentGeoEnrichment servicepremium:user:geoenrichmentAllow application to access the GeoEnrichment service. Learn more
    GeocodingGeocode servicepremium:user:geocodeAllow application to access the geocoding service. Learn more
    RoutingRouting (Network analysis)premium:user:networkanalysisAllow application to access the routing service. Learn more
    RoutingLast milepremium:user:networkanalysis:lastmiledeliveryAllow application to access the routing service and perform routing operations for last mile delivery. Learn more
    CategoryLabelPrivilege stringDescription
    Feature analysisSpatial analysis servicepremium:user:spatialanalysisAllow application to access the spatial analysis service. Learn more
    ContentCreate, update, and deleteportal:user:createItemAllow member to create, edit, and delete their own content. Learn more
    ContentPublish hosted feature layersportal:publisher:publishFeaturesAllow member to publish hosted feature layers from shapefiles, CSVs, etc. Learn more
    Image analysisImage analysis servicepremium:publisher:rasteranalysisAllow application to access image services to perform analysis. Learn more
    ContentPublished hosted tiled imagery layersportal:publisher:publishTiledImageryAllow application to publish hosted tiled imagery layers from a single image or collection of images. Learn more
    ContentPublish hosted dynamic imagery layersportal:publisher:publishDynamicImageryAllow application to publish hosted dynamic imagery layers from a single image or collection of images. Learn more
  3. Select the required privileges and click Next.

Select items (optional)

If your application will require access to specific private items, you will need to configure your developer credentials to access them. The Item access menu allows you to browse your portal's content and grant your key fine-grained access to specific items.

  1. If your token does not require item access, click Skip.

  2. In the Grant item access window, click Browse items.

    Item access button
  3. Select the items you want to grant access to. You can select up to 100 items in this menu.

  4. Click Add items.

Save the item

After configuring the properties of your API key credentials, you can save the credentials as a new item.

  1. In the Create developer credentials window, set the following properties:

    • Title: My OAuth credentials (for app authentication)
    • Folder: Developer credentials (Create a new folder)
    • Tags: Add tags related to the privileges of the credentials.
    • Description: Describe the application that these developer credentials will be used in.
    API key credential details

    Click Next.

  2. In the Summary window, review the properties, privileges, and item access you have set.

  3. Click Create to create your OAuth credentials.

Copy the client ID and client secret

Your OAuth credentials contain client_id and client_secret parameters that are required to implement app authentication. Copy these values and paste them into your application or script.

  1. On the item page of your OAuth credentials, scroll down to Credentials.

  2. Copy the Client ID and Client Secret values and paste them into your application. Never expose the value of your client secret.

    Client credentials

Manage your credentials

After creating an OAuth credentials item, its properties can be managed at any time by going to the item page. The Settings menu allows you to perform the following tasks:

Edit privileges: You can edit the privileges of your OAuth credentials to adjust the authorization level of your application.

  1. Go to Settings on the item page of your OAuth credentials.

  2. Under Application > Privileges, click the Edit privileges button.

    Edit credential privileges
  3. Select new privileges for your API keys using the privileges window. To view a list of all available privileges, go to Privileges.

  4. Click Save. In the warning that appears, click Yes. Your API keys will be reset.

Edit item access: You can edit the items that your OAuth credentials are authorized to access.

  1. Go to Settings on the item page of your OAuth credentials.

  2. Under Application > Privileges, click the Edit item access button.

    Edit credential privileges
  3. Select items to grant your OAuth credentials access to.

  4. Click Save.

Monitor credential usage: You can monitor the usage of your OAuth credentials to track their consumption of services and view billing information.

  1. Go to Settings on the item page of your OAuth credentials.

  2. Under Application > Application usage, click the View usage button.

    View usage

Additional resources

Learn more about app authentication in the following topics:

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.