ArcGIS
An authentication method is a process used to obtain an access token
There are two methods for authenticating users and three types of authentication that can be used to obtain an access token:
- API key: A simple method to authenticate users.
- API key authentication: This creates a long-lived access token that grants your application access to location services
ArcGIS Location Services, also referred to as Location Services, are services hosted by Esri that provide geospatial functionality for developing mapping applications. They include the ArcGIS Basemap Styles service, ArcGIS Static Basemap Tiles service, ArcGIS Places service, ArcGIS Geocoding service, ArcGIS Routing service, ArcGIS GeoEnrichment service, and ArcGIS Elevation service. An ArcGIS Location Platform or ArcGIS Online account is required to use the services. and private content.
- API key authentication: This creates a long-lived access token that grants your application access to location services
- OAuth 2.0: This method uses application credentials
OAuth credentials are an item that contains parameters required to implement user authentication or app authentication, including a to manage and authorize access for authenticated users.client_id,client_secret, and redirect URIs. They are a type of developer credential.- User authentication (formerly ArcGIS identity): This generates a short-lived token via OAuth 2.0, authorizing your application to access ArcGIS content, services, and resources on behalf of a logged-in ArcGIS user.
- App authentication: This generates a short-lived token via OAuth 2.0, authorizing a developer's application to access ready-to-use services
ArcGIS Location Services, also referred to as Location Services, are services hosted by Esri that provide geospatial functionality for developing mapping applications. They include the ArcGIS Basemap Styles service, ArcGIS Static Basemap Tiles service, ArcGIS Places service, ArcGIS Geocoding service, ArcGIS Routing service, ArcGIS GeoEnrichment service, and ArcGIS Elevation service. An ArcGIS Location Platform or ArcGIS Online account is required to use the services. on their behalf.
To make authenticated requests to services, you need to set the token parameter to an access token
API key authentication
An API key is a long-lived access token that authorizes your application to access secure services, content, and functionality in ArcGIS. Using API keys is typically the easiest way to access ArcGIS location services
To use API keys, you need to have one of the following ArcGIS accounts
-
ArcGIS Location Platform account
An ArcGIS Location Platform account, formerly known as an ArcGIS Developer account, is an identity associated with an ArcGIS Location Platform subscription. -
ArcGIS Online account
An ArcGIS Online account, also known as an ArcGIS Organization account, is an identity associated with an ArcGIS Online subscription. It can be used to access ArcGIS tools and develop applications with ArcGIS location services for an organization.
Use API keys when you want to:
- Quickly write applications that consume ready-to-use services.
- Provide access to services without requiring users to sign in with an ArcGIS account
An ArcGIS account is an identity with a user type and set of privileges that can access specific ArcGIS products, tools, APIs, services, and resources. The main account types that can be used for development are an ArcGIS Location Platform account, ArcGIS Online account, and ArcGIS Enterprise account. ArcGIS Location Platform and ArcGIS Online accounts are also associated with a subscription. . - Use an access token
An access token is an authorization string that provides access to secure ArcGIS content, data, and services. Its capabilities are determined by the privileges it supports. It is obtained by implementing API key authentication, User authentication, or App authentication. that doesn't expire. - Meter service usage to the ArcGIS subscription that owns the API key.
Set a global API key for your project
You can set a global API key to use across different scenes in a project.
To set a global API key:
Go to Edit > Project Settings, in the ArcGIS Maps SDK tab, and enter the API key.
Set an API key for a specfic scene
To set an API key for a specific scene:
- You need an ArcGIS Location Platform account or ArcGIS Online account and an API key
An API key is a long-lived access token created using API key credentials. They are valid for up to one year and are typically embedded directly into client applications. to access ArcGIS servicesA service, also known as an ArcGIS service, is software that supports an ArcGIS REST API and provides geospatial functionality or data. A service can be hosted by Esri or in ArcGIS Enterprise. . If you don't have an account, sign up for free. - Open the Map Creator UI in the Unity Editor, and click the Auth tab.
- Set the API key in the API Key field.
With the Map Creator UI, the API key is used for all your content. If you want to use different API keys for each data, use the C# API.
OAuth 2.0
OAuth 2.0 is an industry-standard protocol for authorization. ArcGIS stores private user identities and content; 3rd party applications access those resources through a secure OAuth 2.0 user authorization protocol.
User authentication
User authentication
Implement user authentication when you want to:
- Ensure users are signed in and authenticated with their own ArcGIS account
An ArcGIS account is an identity with a user type and set of privileges that can access specific ArcGIS products, tools, APIs, services, and resources. The main account types that can be used for development are an ArcGIS Location Platform account, ArcGIS Online account, and ArcGIS Enterprise account. ArcGIS Location Platform and ArcGIS Online accounts are also associated with a subscription. . - Meter service usage to your app user's ArcGIS subscription to pay for their private data, content
Content is a collection of items in a portal that belong to a user, group, or organization. , or service transactions. - Limit the length of time users can sign in to your app with a temporary token.
To set up OAuth 2.0 with user authentication:
For the editor mode, there is a sample OAuth challenge handler that allows you to configure OAuth 2.0 with user authentication. To load private data in the Scene view:
- Have an ArcGIS account
An ArcGIS account is an identity with a user type and set of privileges that can access specific ArcGIS products, tools, APIs, services, and resources. The main account types that can be used for development are an ArcGIS Location Platform account, ArcGIS Online account, and ArcGIS Enterprise account. ArcGIS Location Platform and ArcGIS Online accounts are also associated with a subscription. , register an OAuth app, and have a Client ID and Redirect URI for your app to access a private layer. If you don't have an account, sign up for free. - Open the Map Creator UI and click the Auth tab.
- In the Add Authentication Configuration section, set a name for the configuration and introduce the Client ID and the Redirect URI for the private content.
- Click the Add button.
- Click the tab where you have private content, such as Basemap, Elevation, or Layers, and select the configuration name from the Authentication drop-down.
- Save and reload the scene.
When you add a configuration, you can find it under the Authentication Configurations section. When you reload your scene, the login window opens in a default web browser window. To add basemap, elevation, and layers, see the Layers section.
For play mode, you should configure another OAuth challenge handler for your own app. You can attach your own script or the OAuth Challenge Handlers Initializer (which uses the sample scripts) to the game object with the ArcGIS Map Component.
- Click ArcGIS Map in the Hierarchy window.
- In the Inspector window, click the Add Components button.
- Select OAuth Challenge Handlers Initializer.
When the secured feature service data is loaded, the login window will open in the default web browser.
App credential authentication
App credential authenticationclient_id, client_secret, and redirect URIs. They are a type of developer credential.
Use application credentials when you want to:
- Access ready-to-use services with a more secure process and a short-lived token.
- Provide access to services without requiring users to have an ArcGIS account.
Choose an authentication method
The choice of which type of authentication to implement is mostly dependent upon the resources required by your application.
| Scenario | Solution |
|---|---|
| Your app requires access only to ready-to-use services, such as the basemap layer, geocoding, or routing services. | API key |
| Your app allows users to view and edit private data in ArcGIS. | User authentication |
| Your app is API backend and requires access only to basemaps and geocoding. | App credential authentication |