arcgis-authentication
Skill1 starsChanged 6 months agoMITView on GitHub
Authenticate ArcGIS apps with the ArcGIS Maps SDK for JavaScript 5.1: API keys via esriConfig.apiKey for location services, and user sign-in via OAuth2 with OAuthInfo and IdentityManager. Use this skill whenever the user accesses secured content, configures an API key, or sets up OAuth2 / named-user sign-in.
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- GeoDaoyu/arcgis-maps-sdk-js-ai-contexttheir own version, first seen Nov 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- GeoDaoyu/arcgis-maps-sdk-js-ai-context★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository73 other files it gives its agents.
- skills/arcgis-3d-layers/AGENTS.mdAGENTS.md
- skills/arcgis-advanced-layers/AGENTS.mdAGENTS.md
- skills/arcgis-ai-components/AGENTS.mdAGENTS.md
- skills/arcgis-arcade/AGENTS.mdAGENTS.md
- skills/arcgis-authentication/AGENTS.mdAGENTS.md
- skills/arcgis-charts/AGENTS.mdAGENTS.md
- skills/arcgis-cim-symbols/AGENTS.mdAGENTS.md
- skills/arcgis-coding-components/AGENTS.mdAGENTS.md
- skills/arcgis-coordinates-projection/AGENTS.mdAGENTS.md
- skills/arcgis-core-maps/AGENTS.mdAGENTS.md
- skills/arcgis-core-utilities/AGENTS.mdAGENTS.md
- skills/arcgis-custom-rendering/AGENTS.mdAGENTS.md
- skills/arcgis-editing/AGENTS.mdAGENTS.md
- skills/arcgis-embeddable-maps/AGENTS.mdAGENTS.md
- skills/arcgis-feature-effects/AGENTS.mdAGENTS.md
- skills/arcgis-geometry-operations/AGENTS.mdAGENTS.md
- skills/arcgis-imagery/AGENTS.mdAGENTS.md
- skills/arcgis-interaction/AGENTS.mdAGENTS.md
- skills/arcgis-knowledge-graphs/AGENTS.mdAGENTS.md
- skills/arcgis-layers/AGENTS.mdAGENTS.md
- skills/arcgis-map-tools/AGENTS.mdAGENTS.md
- skills/arcgis-parquet/AGENTS.mdAGENTS.md
- skills/arcgis-performance/AGENTS.mdAGENTS.md
- skills/arcgis-popup-templates/AGENTS.mdAGENTS.md
- skills/arcgis-portal-content/AGENTS.mdAGENTS.md
- skills/arcgis-rest-services/AGENTS.mdAGENTS.md
- skills/arcgis-scene-environment/AGENTS.mdAGENTS.md
- skills/arcgis-smart-mapping/AGENTS.mdAGENTS.md
- skills/arcgis-spatial-analysis/AGENTS.mdAGENTS.md
- skills/arcgis-starter-app/AGENTS.mdAGENTS.md
- skills/arcgis-tables-forms/AGENTS.mdAGENTS.md
- skills/arcgis-time-animation/AGENTS.mdAGENTS.md
- skills/arcgis-utility-networks/AGENTS.mdAGENTS.md
- skills/arcgis-visualization/AGENTS.mdAGENTS.md
- skills/arcgis-widgets-advanced/AGENTS.mdAGENTS.md
- skills/arcgis-widgets-ui/AGENTS.mdAGENTS.md
- skills/hello-world/AGENTS.mdAGENTS.md
- arcgis-3d-layersSkill
- arcgis-advanced-layersSkill
- arcgis-ai-componentsSkill
- arcgis-arcadeSkill
- arcgis-chartsSkill
- arcgis-cim-symbolsSkill
- arcgis-coding-componentsSkill
- arcgis-coordinates-projectionSkill
- arcgis-core-mapsSkill
- arcgis-core-utilitiesSkill
- arcgis-custom-renderingSkill
- arcgis-editingSkill
- arcgis-embeddable-mapsSkill
- arcgis-feature-effectsSkill
- arcgis-geometry-operationsSkill
- arcgis-imagerySkill
- arcgis-interactionSkill
- arcgis-knowledge-graphsSkill
- arcgis-layersSkill
- arcgis-map-toolsSkill
- arcgis-parquetSkill
- arcgis-performanceSkill
- arcgis-popup-templatesSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 59
Consider app-credential / token flows server-side.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Authentication
When to use: Activate this skill whenever the user configures an API key, signs in users with OAuth2, or accesses secured ArcGIS content.
Overview
Two models: an API key for location services, and OAuth2 user sign-in for org content.
- Problem it solves: authorizing access to billed services and private content.
- Who it serves: developers wiring auth into ArcGIS apps.
- Pattern it teaches:
esriConfig.apiKeyfor keys;OAuthInfo+IdentityManagerfor users. - What it does NOT cover: which services need auth (see
arcgis-rest-services/arcgis-portal-content).
Quick Start
import esriConfig from "@arcgis/core/config.js";
esriConfig.apiKey = import.meta.env.VITE_ARCGIS_API_KEY as string;Decision Tree
- Just calling location services (basemaps, geocode, route)?
- Yes → an API key from API key credentials (
esriConfig.apiKey), with referrer restrictions and an expiration you track.
- Yes → an API key from API key credentials (
- Accessing a user's private org content / editing secured layers?
- Yes → OAuth2 with
OAuthInfo+IdentityManager(defaultflowType: "auto": two-step with PKCE where the server supports it;"implicit"only for servers older than 10.9).
- Yes → OAuth2 with
- Enterprise / app login (not per-user)?
- Consider app-credential / token flows server-side; never ship secrets to the browser.
Default: API key for public services; OAuth2 for named-user access.
Import Patterns
Direct ESM (recommended for npm/Vite/Webpack)
import OAuthInfo from "@arcgis/core/identity/OAuthInfo.js";
import IdentityManager from "@arcgis/core/identity/IdentityManager.js";Dynamic Imports (CDN)
const esriConfig = await $arcgis.import("@arcgis/core/config.js");Map Components (recommended for new projects)
// Set esriConfig.apiKey (or register OAuth) before the map component loads.
import "@arcgis/map-components/components/arcgis-map";Key Concepts
Concept 1: API keys
esriConfig.apiKey authorizes requests with that key's privileges. Read it from the environment so
it stays out of git — but know that import.meta.env.VITE_* is inlined into the public
bundle: every visitor can read the key. What protects it is configured on the API key
credentials item, not in code:
- Referrer restrictions (only your domains can use it) and the minimum privileges.
- Expiration: keys from API key credentials last up to one year. Two keys per credential, with staggered expirations, let you rotate without downtime.
- Legacy keys are gone: API keys created before June 27, 2024 (
AAPK…) were retired on June 27, 2026 and now answer "Invalid Token". Migrate them to API key credentials.
A key is an app identity, not a user: it can be granted access to specific private items, but per-user permissions (who may edit what) need OAuth.
Concept 2: OAuth2 flow
new OAuthInfo({ appId, popup }) + IdentityManager.registerOAuthInfos([info]) sets up sign-in.
The SDK then prompts when a request hits secured content; IdentityManager.checkSignInStatus resumes.
Concept 3: appId is public
The OAuth appId (client id) is a public identifier — safe in the browser. There is no client
secret in the implicit/PKCE browser flow; never embed secrets client-side.
Common Pitfalls (Top 3)
Pitfall 1: Hardcoding the API key
// ❌ Anti-pattern
esriConfig.apiKey = "AAPK_real_key";// ✅ Correct
esriConfig.apiKey = import.meta.env.VITE_ARCGIS_API_KEY as string;Impact: the key leaks into source control; gitleaks blocks it. The env variable only keeps it out of git: it still ships in the bundle, so restrict its referrers and privileges.
Pitfall 2: Putting a client secret in the browser
// ❌ Anti-pattern
const info = new OAuthInfo({ appId, /* secret */ });// ✅ Correct
const info = new OAuthInfo({ appId, popup: false }); // PKCE/implicit; no secret client-sideImpact: a leaked secret compromises the app registration.
Pitfall 3: Registering OAuth after the first secured request
// ❌ Anti-pattern
await layer.load(); // hits secured content first
IdentityManager.registerOAuthInfos([info]); // too late// ✅ Correct
IdentityManager.registerOAuthInfos([info]); // register first
await layer.load();Impact: the request does not fail: measured with SDK 5.1.27, a secured layer (or a geocode
call with no key) opens the SDK's own username/password dialog (.esri-identity-modal) and the
promise waits on it. Your OAuth flow never runs for that request.
When to Read references/
| If you need... | Read |
| esriConfig / OAuthInfo / IdentityManager | references/api-detail.md |
| API key + OAuth examples | references/examples.md |
| More pitfalls (5+ extended) | references/pitfalls.md |
Related Skills
arcgis-rest-services— services that need a keyarcgis-portal-content— private content needs sign-inarcgis-starter-app— env-var setup for keys
Reference Samples
Changelog
- 0.2.0 (2026-10-27): SDK 5.1. Env variables do not hide a key (it ships in the bundle); referrer
restrictions, expiration and rotation; legacy
AAPKkeys retired on 2026-06-27; OAuth registered late opens the SDK's username/password dialog instead of failing (measured);flowTypedefaultauto; API key credentials can be granted private items. Run intests/runtime/casos/arcgis-authentication.ts. - 0.1.0 (2026-05-31): Initial release.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

