-
Notifications
You must be signed in to change notification settings - Fork 1.2k
App Authentication using API Key Credentials added #2462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Changes from 29 commits
43161fc
f9292f1
d34914e
9cb597b
fc64381
4902621
42305c1
efc5e9f
5cdc7af
369d489
c0aec36
7871ef6
bb57f42
7ee6470
b977261
8a334a8
4e515f0
f53b8d2
afb1cb4
0ce15ea
2b47ccb
35069f4
1e39fef
c0adaed
bdc6ed4
2d1a15b
98638cd
1af7a23
b46eb6a
b074e03
10dd77e
855c6a2
348b8ba
5fff62b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -453,6 +453,96 @@ | |
| "The recommended suggestion for non-interactive login scripts is to use the built-in identity provider instead of SAML." | ||
tarunkukreja003 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## App Authentication using API Key Credentials" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "This workflow demonstrates how to use an Administrative connection to register a new Application, define its security boundaries (Privileges, Expiration, and Referers), and subsequently initialize a restricted GIS session using the generated `client_id`" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "##### 1. Establish Administrative Connection\n", | ||
| "Before creating credentials, you must connect to your Portal as an Administrator. This \"Master Connection\" is used to manage the lifecycle of your application identities." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "from arcgis.gis import GIS\n", | ||
| "\n", | ||
| "# Initialize the Admin session\n", | ||
| "gis_admin = GIS(url=\"your_organization_url\", username=\"your_admin_username\", password=\"your_admin_ password\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "##### 2. Creating the App Identity\n", | ||
| "\n", | ||
| "The `developer_credentials.create` is a method of the `DeveloperCredentialManager` class that registers the app. Here, we define the \"Security Perimeter\" of the application before it ever logs in." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "from arcgis.gis.admin._stokenmgr import TokenPrivilege\n", | ||
jyaistMap marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "import datetime as dt\n", | ||
| "\n", | ||
| "# Define the restricted sandbox\n", | ||
| "apiKeyCredentials = gis_admin.admin.developer_credentials.create(\n", | ||
| " title=\"API Key Credentials\",\n", | ||
| " privileges=[TokenPrivilege.PORTAL_USER_VIEWORGUSERS], # Restricted Scope\n", | ||
| " expiration=dt.datetime(2026, 3, 8, 11, 29, 22), # Time-limited\n", | ||
| " referers=[\"https://example.com\"] # Domain-locked\n", | ||
| ")\n", | ||
| "\n", | ||
| "# Retrieve the Client ID (The App's Username) and the Client Secret (The App's Password)\n", | ||
| "client_id = apiKeyCredentials.app_info['client_id']" | ||
|
||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "##### 3. Initializing the App Session (App Authentication)\n", | ||
| "\n", | ||
| "Now, we initialize a new GIS object using the `client_id`. This session is App-authenticated. It does not represent the Admin; it represents the \"API Key Credentials\" app itself." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Authenticate as the App\n", | ||
| "gis_app = GIS(url=\"https://arcgis.com\", client_id=client_id)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "After running the above cell, it will ask for a token. A browser window will be open up, copy the token from the browser" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": {}, | ||
|
|
@@ -655,7 +745,7 @@ | |
| "name": "python", | ||
| "nbconvert_exporter": "python", | ||
| "pygments_lexer": "ipython3", | ||
| "version": "3.13.5" | ||
| "version": "3.13.7" | ||
| }, | ||
| "toc": { | ||
| "base_numbering": 1, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.