<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using Python to generate access token for an account that uses organization login in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1184479#M4182</link>
    <description>&lt;P&gt;Did it end up working?&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jun 2022 20:56:09 GMT</pubDate>
    <dc:creator>alex_friant</dc:creator>
    <dc:date>2022-06-20T20:56:09Z</dc:date>
    <item>
      <title>Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133618#M4053</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;&lt;P&gt;I've been trying to generate a REST API access token for an item on ArcGIS online through a basic Python script and I'm having a hard time.&lt;/P&gt;&lt;P&gt;Here are the URLs of the item that I want to access:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;ArcGIS Online URL:&amp;nbsp;&lt;A href="https://jacobs.maps.arcgis.com/home/item.html?id=41f6ee459c664aeb98a3fab39139c896" target="_blank" rel="noopener"&gt;https://mycompany.maps.arcgis.com/home/item.html?id=41f6ee459c664aeb98a3fab39139c896&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;REST API URL:&amp;nbsp;&lt;A href="https://services9.arcgis.com/eNX73FDxjlKFtCtH/arcgis/rest/services/I20_Aecom_Segments/FeatureServer" target="_blank" rel="noopener"&gt;https://services9.arcgis.com/eNX73FDxjlKFtCtH/arcgis/rest/services/layername/FeatureServer&lt;/A&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Note: You won't be able to access the item above because it's not shared publicly (which is why I want to generate an access token in the first place).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I followed the instructions found &lt;A href="https://community.esri.com/t5/arcgis-rest-api-questions/generate-token-in-rest/m-p/220854#M1083" target="_blank" rel="noopener"&gt;here (Generate Token in REST)&lt;/A&gt; and arrived at the following Python code (substituting the placeholders with my actual username and password):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests
tokenURL = 'https://services9.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 
          'username': 'placeholder_username', 
          'password': 'placeholder_password', 
          'referer': 'http://www.arcgis.com'}
response = requests.post(tokenURL, data = params, verify = False)
token = response.json()['token']&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that the code above doesn't work. When I investigate the &lt;FONT face="courier new,courier"&gt;response&lt;/FONT&gt; object, I notice two things:&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;It doesn't have a "&lt;FONT face="courier new,courier"&gt;token&lt;/FONT&gt;" key.&lt;/LI&gt;&lt;LI&gt;It tells me that the URL I used is invalid.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;print(response.json()) 
# {'error': {'code': 400, 'message': 'Invalid URL', 'details': ['Invalid URL']}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I tried using &lt;FONT face="courier new,courier"&gt;tokenURL='&lt;A href="https://www.arcgis.com/sharing/rest/generateToken" target="_blank" rel="noopener"&gt;https://www.arcgis.com/sharing/rest/generateToken&lt;/A&gt;'&lt;/FONT&gt;, but that didn't work either:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;print(response.json()) 
# {'error': {'code': 400, 'message': 'Unable to generate token.', 'details': ['Invalid username or password.']}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I believe this might be because I typically log into ArcGIS online through my organization's URL: mycompany.maps.arcgis.com (as seen below):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FelipeDias_0-1677171213329.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63536i24C1136D7D524905/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FelipeDias_0-1677171213329.png" alt="FelipeDias_0-1677171213329.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I finally tried to use&amp;nbsp;&lt;FONT face="courier new,courier"&gt;tokenURL='&lt;A href="https://jacobs.maps.arcgis.com/sharing/rest/generateToken" target="_blank" rel="noopener"&gt;https://mycompany.maps.arcgis.com/sharing/rest/generateToken&lt;/A&gt;'&lt;/FONT&gt;, but that didn't work either:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;print(response.json()) 
# {'error': {'code': 400, # 'message': 'Unable to generate token.', # 'details': ['Invalid username or password.']}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know what I need to do to successfully generate an access token for the item above?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 16:56:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133618#M4053</guid>
      <dc:creator>FelipeDias</dc:creator>
      <dc:date>2023-02-23T16:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133684#M4054</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/473765"&gt;@FelipeDias&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Try using this endpoint instead&amp;nbsp;&lt;A href="https://www.arcgis.com/sharing/generateToken" target="_blank" rel="noopener"&gt;/sharing/generateToken&lt;/A&gt;&amp;nbsp;. Your request should be something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests
organisationName = "orgName"
url = f"https://{organisationName}.maps.arcgis.com/sharing/generateToken"

username = "NamedUserAccount"
password = "Password123"

payload={'f': 'json',
'username': username,
'password': password,
'referer': f"https://{organisationName}.maps.arcgis.com/"}

response = requests.request("POST", url, data=payload)

print(response.json())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can check to see if the token works by requesting some content from your named user's contents with the following request:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;organisationName = "orgName"

url = f"https://{organisationName}.maps.arcgis.com/sharing/rest/content/users/{username}"

token = response.json()['token']
params={
    'f':'json',
    'num':1,
    'token': token
}

userContents = requests.request("GET", url, params=params)

print(userContents.json())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:35:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133684#M4054</guid>
      <dc:creator>LongDinh</dc:creator>
      <dc:date>2022-01-13T23:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133686#M4055</link>
      <description>&lt;P&gt;Thanks for the quick reply!!! Sadly, it didn't work, though... This is what got inside the `response` item:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;print(response.json())&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;{'error': {'code': 400, 
 'message': 'Unable to generate token.', 
 'details': ['Invalid username or password.']}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Any idea what's going on?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:41:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133686#M4055</guid>
      <dc:creator>FelipeDias</dc:creator>
      <dc:date>2022-01-13T23:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133688#M4056</link>
      <description>&lt;P&gt;Are you using a valid account? It needs to be a named user account&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:44:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133688#M4056</guid>
      <dc:creator>LongDinh</dc:creator>
      <dc:date>2022-01-13T23:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133694#M4057</link>
      <description>&lt;P&gt;I am. Here's a snapshot of my user profile (I've edited the actual username for privacy):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FelipeDias_0-1677171344188.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/63538iB775741DB071132E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FelipeDias_0-1677171344188.png" alt="FelipeDias_0-1677171344188.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But as I mentioned in my original post, I don't log in to ArcGIS online though the default portal. Instead, I use my company's organization URL. I have the feeling that &lt;STRONG&gt;that&lt;/STRONG&gt; is what's causing the issues here.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 16:55:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133694#M4057</guid>
      <dc:creator>FelipeDias</dc:creator>
      <dc:date>2023-02-23T16:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133698#M4058</link>
      <description>&lt;P&gt;That looks like a Azure Directory account linked to your organisation's ArcGIS Online. You should either:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Use your organisation's ArcGIS Online named user administration account, or&lt;/LI&gt;&lt;LI&gt;Have your&amp;nbsp;ArcGIS Online named user administration account create a named user for purposes of generating tokens.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The later is generally the preferred solution as you should set up the contents/groups shared to the named user so that it has limited access to items in your organisation's ArcGIS Online&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 00:07:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133698#M4058</guid>
      <dc:creator>LongDinh</dc:creator>
      <dc:date>2022-01-14T00:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133700#M4059</link>
      <description>&lt;P&gt;Great, I'll reach out to our IT folks and see if they can generate that for me. I'll report back here if it worked later! Thanks!!!!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 00:13:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1133700#M4059</guid>
      <dc:creator>FelipeDias</dc:creator>
      <dc:date>2022-01-14T00:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1184479#M4182</link>
      <description>&lt;P&gt;Did it end up working?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 20:56:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1184479#M4182</guid>
      <dc:creator>alex_friant</dc:creator>
      <dc:date>2022-06-20T20:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1346862#M4602</link>
      <description>&lt;P&gt;Also would like to know if it worked.&amp;nbsp; I work for the City and sign in through our organizations login.&amp;nbsp; I have a script that i run but get the following error message:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error:&lt;STRONG&gt; Line 34 -- "token = response.json()['token']": 'token'&lt;/STRONG&gt;&lt;BR /&gt;Failed script Attachments to Popup...&lt;BR /&gt;&lt;STRONG&gt;Failed to execute (AttachmentstoPopup).&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 19:42:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1346862#M4602</guid>
      <dc:creator>MarkGambordella</dc:creator>
      <dc:date>2023-11-07T19:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1347453#M4603</link>
      <description>&lt;P&gt;I found a work around.&amp;nbsp; Had to create a built-in account and use that as the user/password instead of the SAML account.&amp;nbsp; It worked and was able to generate a token using this geoprocessing tool below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-online-documents/show-attachments-in-web-map-popup/ta-p/918926/page/9/show-comments/true" target="_blank"&gt;Show Attachments in Web Map Popup - Page 9 - Esri Community&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 21:46:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1347453#M4603</guid>
      <dc:creator>MarkGambordella</dc:creator>
      <dc:date>2023-11-08T21:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1357054#M4624</link>
      <description>&lt;P&gt;Hi Mark, would you mind sharing your method of accessing the token with a built-in user, not using user/pass. I had been accessing it using:&amp;nbsp;&lt;/P&gt;&lt;P&gt;gis=GIS('home')&lt;BR /&gt;token=gis._con.token&lt;/P&gt;&lt;P&gt;but that code isn't working anymore, and I'm at a loss to find why, or a workaround.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 18:56:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1357054#M4624</guid>
      <dc:creator>DCWORK_GIS</dc:creator>
      <dc:date>2023-12-05T18:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1357075#M4625</link>
      <description>&lt;P&gt;I was able to find a work around for now.&amp;nbsp; you cannot use your SAML account but instead have to create a built-in account.&amp;nbsp; Use the built-in account for your user:password in the geoprocessing tool found in the link below.&amp;nbsp; the tool creates a URL for only the first attachment (which is the only one I needed), the URL with a token is added to the attribute table.&amp;nbsp; because the token expires, you can then run a script to update the token once a week.&amp;nbsp; the links below were helpful in setting it up.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-online-documents/show-attachments-in-web-map-popup/ta-p/918926" target="_blank" rel="noopener"&gt;Show Attachments in Web Map Popup - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=WpLJBZ9gnuw" target="_blank" rel="nofollow noopener noreferrer"&gt;Attachments to Popup - YouTube&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=yRwuhV66av4" target="_blank" rel="nofollow noopener noreferrer"&gt;Schedule a Python Script using Windows Task Scheduler - YouTube&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 19:27:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1357075#M4625</guid>
      <dc:creator>MarkGambordella</dc:creator>
      <dc:date>2023-12-05T19:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1684285#M5090</link>
      <description>&lt;P&gt;Unless you use the built-in accounts only way to do this is to interactive login&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="https://developers.arcgis.com/python/latest/guide/working-with-different-authentication-schemes/#User-authentication-with-OAuth-2.0" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-enterprise-questions/unable-to-generate-tokens-using-saml-enterprise/m-p/1055634#M30127&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;see excerpt below&lt;/STRONG&gt;&lt;/P&gt;&lt;H2&gt;&lt;STRONG&gt;User authentication with OAuth 2.0&lt;/STRONG&gt;&lt;/H2&gt;&lt;P&gt;&lt;STRONG&gt;The ArcGIS Python API supports&amp;nbsp;&lt;A href="https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/what-is-oauth-2/" target="_blank" rel="noopener"&gt;OAuth 2.0&lt;/A&gt;&amp;nbsp;as an authentication method, and acts as a&amp;nbsp;&lt;A href="https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/mobile-and-native-user-logins/" target="_blank" rel="noopener"&gt;serverless native application&lt;/A&gt;&amp;nbsp;when using OAuth 2.0 authorization with ArcGIS.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;To use this mode of authorization, you need a&amp;nbsp;client id. If you already have a client id, you can skip the following section.&lt;/STRONG&gt;&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;Obtaining a client id&lt;/STRONG&gt;&lt;/H3&gt;&lt;P&gt;&lt;STRONG&gt;The steps below show how a client id can be obtained by registering a new application with your GIS. Only one client id is required, so if your GIS has one already, you may use it instead of creating a new application.&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;Log in to your ArcGIS Online or ArcGIS Enterprise organization.&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Go to the Content tab.&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Click 'New item', then select 'Application'.&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;On the 'New item' dialog, select 'Other application' and click 'Next'.&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Type in a title for the application item. Optionally, specify the folder, tags, and summary.&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Click 'Save' to add the item.&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;On the item details page of this newly created application, browse to the Credentials section and find the Client ID. The string listed is the value that you will pass in as the&amp;nbsp;client_id&amp;nbsp;parameter when creating the GIS object.&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;You can then log on to your org using the Python API using the code shown below:&lt;/STRONG&gt;&lt;/P&gt;&lt;H5&gt;&lt;STRONG&gt;Interactive Login Experience&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;This uses interactive sign-in experience: you would be redirected to your organization's sign-in page using the configured identity provider. Upon signing in, you would get a code that you can paste back to complete the sign-in process:&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;STRONG&gt;gis = GIS(&lt;SPAN class=""&gt;"https://pythonapi.playground.esri.com/portal"&lt;/SPAN&gt;, client_id=&lt;SPAN class=""&gt;'f8cRxbP3NO8bf9ag'&lt;/SPAN&gt;)
&lt;SPAN class=""&gt;print&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"Successfully logged in as: "&lt;/SPAN&gt; + gis.properties.user.username)&lt;/STRONG&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;STRONG&gt;Please sign in to your GIS and paste the code that is obtained below.
If a web browser does not automatically open, please navigate to the URL below yourself instead.
Opening web browser to navigate to: https://pythonapi.playground.esri.com/portal/sharing/rest/oauth2/authorize?client_id=f8cRxbP3NO8bf9ag&amp;amp;response_type=code&amp;amp;expiration=-1&amp;amp;redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob
Enter code obtained on signing in using SAML: ········
Successfully logged in as: arcgis_python&lt;/STRONG&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;H5&gt;&lt;STRONG&gt;Non-Interactive Login Experience&lt;/STRONG&gt;&lt;/H5&gt;&lt;P&gt;&lt;STRONG&gt;The recommended suggestion for non-interactive login scripts is to use the built-in identity provider instead of SAML.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Feb 2026 13:03:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1684285#M5090</guid>
      <dc:creator>DurmusCesar</dc:creator>
      <dc:date>2026-02-13T13:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using Python to generate access token for an account that uses organization login</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1684286#M5091</link>
      <description>&lt;P&gt;Exactly or use interactive login with clientID (this works in case of SAML accounts)&lt;/P&gt;</description>
      <pubDate>Fri, 13 Feb 2026 13:04:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/using-python-to-generate-access-token-for-an/m-p/1684286#M5091</guid>
      <dc:creator>DurmusCesar</dc:creator>
      <dc:date>2026-02-13T13:04:56Z</dc:date>
    </item>
  </channel>
</rss>

