<?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: Can I use a token with ArcGIS API for Python? in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69598#M3322</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had a similar question posted in 2017. I had a JS app that did SAML user login into AGOL and received a token. I wanted to pass that token to a Python module (using ArcGIS API for Python).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the time the only suggestion I was given was to hack it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;/P&gt;&lt;P&gt;my_gis = GIS()&lt;/P&gt;&lt;P&gt;con = my_gis._con&lt;BR /&gt; con._token = mytoken&lt;BR /&gt;&lt;SPAN&gt; my_gis._url = '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fmyorg.maps.arcgis.com" rel="nofollow" target="_blank"&gt;https://myorg.maps.arcgis.com&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con._url = '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fmyorg.maps.arcgis.com" rel="nofollow" target="_blank"&gt;https://myorg.maps.arcgis.com&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Frankly I never got this to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only recently, my questions was answered and I was referred to the latest API which now includes a kwargs section in the GIS object that lets you specify a token if user/pass is empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#gis" title="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#gis"&gt;arcgis.gis module — arcgis 1.4.0 documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There seem to be no samples provided so I just tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;my_gis = GIS(url='&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;myorg&lt;/SPAN&gt;&lt;SPAN&gt;.maps.arcgis.com&lt;/SPAN&gt;', token='mytokenvalue')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;No luck still.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Apr 2018 08:51:13 GMT</pubDate>
    <dc:creator>GeofyAdmin</dc:creator>
    <dc:date>2018-04-20T08:51:13Z</dc:date>
    <item>
      <title>Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69591#M3315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm interested in using the &lt;A href="https://developers.arcgis.com/python/guide/" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcGIS API for Python &lt;/A&gt;to connect to an ArcGIS Online for Organizations account via a token, and &lt;SPAN style="text-decoration: underline;"&gt;&lt;EM&gt;not&lt;/EM&gt;&lt;/SPAN&gt; a username/password.&amp;nbsp;All the examples I have found look like this:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #008000; font-weight: bold;"&gt;from&lt;/SPAN&gt; &lt;SPAN class="" style="color: #0000ff; font-weight: bold;"&gt;arcgis.gis&lt;/SPAN&gt; &lt;SPAN class="" style="color: #008000; font-weight: bold;"&gt;import&lt;/SPAN&gt; &lt;SPAN class=""&gt;GIS
&lt;/SPAN&gt;&lt;SPAN class=""&gt;gis&lt;/SPAN&gt; &lt;SPAN class="" style="color: #666666;"&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;GIS&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #ba2121;"&gt;"portal url"&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #ba2121;"&gt;"username"&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #ba2121;"&gt;"password"&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How would I pass a token into this API, instead of username/password?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case it matters, I want to connect to ArcGIS Online for Organizations, so my user name is &amp;lt;user&amp;gt;_&amp;lt;org_suffix&amp;gt;. My organization does not use an Enterprise Login, so I just log in directly at the Esri site.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bonus question: I know how to generate the token with Python and the REST API (using&amp;nbsp; JSON). Any idea how to do so with the ArcGIS API for Python?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks, David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:39:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69591#M3315</guid>
      <dc:creator>DavidAskov1</dc:creator>
      <dc:date>2021-12-10T22:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69592#M3316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS

gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

dir&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;gis&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Out&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;137&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'__class__'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; snip &lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
 &lt;SPAN class="string token"&gt;'_server_list'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'_tools'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'_url'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'_username'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'_verify_cert'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'content'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'groups'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'map'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'properties'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'update_properties'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'users'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

help&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;gis&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
help on GIS &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; module arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis object&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;class&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;GIS&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;builtins&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;object&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; _gis&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; 
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; A GIS &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; representative of ArcGIS Online &lt;SPAN class="operator token"&gt;or&lt;/SPAN&gt; ArcGIS Enterprise&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; The GIS object provides helper objects to manage
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; create&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; retrieve&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; GIS resources such &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; content&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; users&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;and&lt;/SPAN&gt; groups&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; 
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; Additionally&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; the GIS object has properties to query it's state&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; which &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; accessible using the properties attribute&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; 
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; The GIS provides a mapping widget that can be used &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; the Jupyter Notebook environment &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; visualizing GIS content
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; well &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; the results of your analysis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; To create a new map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; call the map&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; method&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
 &lt;SPAN class="operator token"&gt;|&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;provides anonymous login apparent... give it whirl&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:39:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69592#M3316</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-10T22:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69593#M3317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I not sure about a token, but from a admin (for moving items to new user, etc) sample and some messing around, this is what I use to connect:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(edit: btw, I'm also hoping to figure out a better way with a token or at least a hidden encrypted pasword...just havent' messed with that yet)&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;# standard modules to load
from arcgis.gis import GIS
from IPython.display import display
from getpass import getpass

#&amp;nbsp; the organizational admin account to use.&amp;nbsp; This is a generic one to be used for administration tasks only
adminuser = "an_adminuser"
#&amp;nbsp; the URL to our organizational account
ourAGOLOrg = "https://ourorg.maps.arcgis.com"

# Set password variable..enter the password for the admin user specified above. e.g. alaskafishandgame 
# will prompt for password, will display *** as you type and ...&amp;nbsp; after
password = getpass()

#Create a connection to the portal. In this case, we will exercise the verify_cert option to not validate the SSL certificate (True by default).

#&amp;nbsp; make sure the correct admin user and password are set above
#&amp;nbsp;&amp;nbsp; If it works, will not return anything and will skip to next box.&amp;nbsp; 
#&amp;nbsp;&amp;nbsp; If credentials are bad, will return an error message.
gis = GIS(ourAGOLOrg, adminuser, password, verify_cert=False)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:39:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69593#M3317</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-10T22:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69594#M3318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan, I noodled around with this a bit. Not sure how this&amp;nbsp;would work. I did note that if I put in bogus credentials, I get back an error that it cannot generate a token (which makes sense). I guess my question is still how would I skip the user/pass checking if I already have a token that was supplied?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fxxx.maps.arcgis.com%2F" target="_blank"&gt;https://xxx.maps.arcgis.com/&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; username&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'xxx'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; password&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'xxx'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
Unable to generate token&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
Invalid username &lt;SPAN class="operator token"&gt;or&lt;/SPAN&gt; password&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
Traceback &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;most recent call last&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"C:\Python36\lib\site-packages\arcgis\gis\__init__.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;257&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; __init__
 client_id&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_client_id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"C:\Python36\lib\site-packages\arcgis\_impl\portalpy.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;163&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; __init__
 client_id&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;client_id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"C:\Python36\lib\site-packages\arcgis\_impl\connection.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;284&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; __init__
 self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;login&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;username&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; password&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; expiration&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; client_id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"C:\Python36\lib\site-packages\arcgis\_impl\connection.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;532&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; login
 newtoken &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;generate_token&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;username&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; password&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; expiration&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; client_id&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"C:\Python36\lib\site-packages\arcgis\_impl\connection.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;397&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; generate_token
 ssl&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; add_token&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"C:\Python36\lib\site-packages\arcgis\_impl\connection.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;1129&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; post
 self&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_handle_json_error&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;resp_json&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'error'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; errorcode&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"C:\Python36\lib\site-packages\arcgis\_impl\connection.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;1149&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; _handle_json_error
 &lt;SPAN class="keyword token"&gt;raise&lt;/SPAN&gt; RuntimeError&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;errormessage&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
RuntimeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Unable to generate token&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
Invalid username &lt;SPAN class="operator token"&gt;or&lt;/SPAN&gt; password&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Error Code&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;400&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
During handling of the above exception&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; another exception occurred&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
Traceback &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;most recent call last&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"&amp;lt;input&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;module&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;
 File &lt;SPAN class="string token"&gt;"C:\Python36\lib\site-packages\arcgis\gis\__init__.py"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; line &lt;SPAN class="number token"&gt;264&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; __init__
 &lt;SPAN class="keyword token"&gt;raise&lt;/SPAN&gt; RuntimeError&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;e&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;args&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
RuntimeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Unable to generate token.\nInvalid username or password.\n(Error Code: 400)'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:39:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69594#M3318</guid>
      <dc:creator>DavidAskov1</dc:creator>
      <dc:date>2021-12-10T22:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69595#M3319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Rebecca. I didn't specify, but I'd like this to run headless without a user prompt.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jan 2018 19:19:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69595#M3319</guid>
      <dc:creator>DavidAskov1</dc:creator>
      <dc:date>2018-01-24T19:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69596#M3320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I king of suspected that (my edit about not getting it any further), but thought that might help you or others in future.&amp;nbsp; I also would like a headless option.&amp;nbsp; Trying to set things up for not admin users.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;btw...you can hard code the password variable instead of using getpass....but I wouldn't think that would be desirable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jan 2018 19:22:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69596#M3320</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2018-01-24T19:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69597#M3321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed, hard-coding the password was what I was trying to avoid... I was thinking of generating a token (they seem to have a 2-week max length for AGOL) on some interval and putting it somewhere my code can access it, but no such luck. Generating a profile will at least get the storage out of my code and my Git repo, but it's still in clear text on the hard drive...&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fxxx.maps.arcgis.com%2F" target="_blank"&gt;https://xxx.maps.arcgis.com/&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; username&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'xxx'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; password&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'xxx'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; profile&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'my_profile'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm honestly thinking it is just easier to send JSON to the REST endpoint than to use the ArcGIS API for Python.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:39:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69597#M3321</guid>
      <dc:creator>DavidAskov1</dc:creator>
      <dc:date>2021-12-10T22:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69598#M3322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had a similar question posted in 2017. I had a JS app that did SAML user login into AGOL and received a token. I wanted to pass that token to a Python module (using ArcGIS API for Python).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the time the only suggestion I was given was to hack it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from arcgis.gis import GIS&lt;/P&gt;&lt;P&gt;my_gis = GIS()&lt;/P&gt;&lt;P&gt;con = my_gis._con&lt;BR /&gt; con._token = mytoken&lt;BR /&gt;&lt;SPAN&gt; my_gis._url = '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fmyorg.maps.arcgis.com" rel="nofollow" target="_blank"&gt;https://myorg.maps.arcgis.com&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; con._url = '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fmyorg.maps.arcgis.com" rel="nofollow" target="_blank"&gt;https://myorg.maps.arcgis.com&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Frankly I never got this to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only recently, my questions was answered and I was referred to the latest API which now includes a kwargs section in the GIS object that lets you specify a token if user/pass is empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#gis" title="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#gis"&gt;arcgis.gis module — arcgis 1.4.0 documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There seem to be no samples provided so I just tried:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;my_gis = GIS(url='&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;myorg&lt;/SPAN&gt;&lt;SPAN&gt;.maps.arcgis.com&lt;/SPAN&gt;', token='mytokenvalue')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;No luck still.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2018 08:51:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69598#M3322</guid>
      <dc:creator>GeofyAdmin</dc:creator>
      <dc:date>2018-04-20T08:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69599#M3323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The authentication is handled when you call gis class in the ArcGIS Python API. Using the python API, tokens and authentication are provided by the api so you don't need to manually create and append tokens to each request. YOu can still use tokens and send direct rest calls using the rest api if desired:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/rest/users-groups-and-items/generate-token.htm" title="https://developers.arcgis.com/rest/users-groups-and-items/generate-token.htm"&gt;Generate Token—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example Script:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://www.arcgis.com/home/item.html?id=f448101c080d4edb8991fb79da818915" title="http://www.arcgis.com/home/item.html?id=f448101c080d4edb8991fb79da818915"&gt;http://www.arcgis.com/home/item.html?id=f448101c080d4edb8991fb79da818915&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As a rule of thumb, never embed a token or username and password in a script that users have access to. With any of these components a potentially malicious user could access your content and resources as your username. If you are looking to authenticate on behalf of users in a public application, check out the app login workflow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/accessing-arcgis-online-services/" title="https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/accessing-arcgis-online-services/"&gt;Implementing App Login | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Kelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Apr 2018 21:55:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69599#M3323</guid>
      <dc:creator>KellyGerrow</dc:creator>
      <dc:date>2018-04-25T21:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69600#M3324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you get any solution for this?&amp;nbsp;Please share your workout with code sample that will great.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arun&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Sep 2018 18:59:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69600#M3324</guid>
      <dc:creator>arunepuri1</dc:creator>
      <dc:date>2018-09-11T18:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69601#M3325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, not in the Python API. It sounds like it intentionally abstracts it for you. Note that if you put in a bad user/pass combination, the error will say it was unable to generate a token.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might be able to open the wheel file and figure out how they do it, but that might violate the EULA, but more importantly, you'd be maintaining your own code, which defeats the purpose of using an API that's supposed to do basic stuff like this for you. Kelly posted some links on how to do it with the REST API, which you could easily automate with&amp;nbsp;Python.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just went with creating a "profile" in the GIS() constructor.&amp;nbsp;It leaves your user/pass sitting around on&amp;nbsp;a server, so you just want to make sure that is appropriately locked down. Since the tokens only last two weeks, I would probably automate&amp;nbsp;a solution to create a new one. I was thinking I might run that on my PC and FTP it over to the server. In the end, that seems too fragile to depend on a desktop machine, so automation would send me back to having my username and password sitting around on a server. With all paths leading to my user/pass sitting on a server, I didn't perceive that there was any benefit to pursuing this further... I wish we could create a longer length token, like you can with ArcGIS Server (up to one year).&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 17:41:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69601#M3325</guid>
      <dc:creator>DavidAskov1</dc:creator>
      <dc:date>2018-09-12T17:41:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69602#M3326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually David and all, this has already been resolved starting with ArcGIS for Python version 1.4. Make sure you have updated to this or latest 1.5 version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The GIS class has been extended to take a token as part of the kwargs optional keyword arguments.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#gis" title="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#gis"&gt;arcgis.gis module — arcgis 1.5.0 documentation&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code below assumes connecting to arcgis.com and uses a token (it will also connect to your organizational account in agol).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AGOLConnection = GIS(token=agolToken)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if you wanted to connect to your own portal then provide the url parameter.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is resolve now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 20:14:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69602#M3326</guid>
      <dc:creator>GeofyAdmin</dc:creator>
      <dc:date>2018-09-12T20:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69603#M3327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/293496"&gt;Geofy Admin&lt;/A&gt;‌ - Thanks for the info. Glad to hear they're listening to our forum posts! I am using an earlier version, so will look to upgrade the next time I re-open this project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The docs&amp;nbsp;say this is only for built-in security - does that mean this is not available when using enterprise logins?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 22:06:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69603#M3327</guid>
      <dc:creator>DavidAskov1</dc:creator>
      <dc:date>2018-09-12T22:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69604#M3328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="color: #333333;"&gt;Hi David,&lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt;Regarding your question about support for Enterprise Logins (i.e. enterprise identity stores served through LDAP providers like AD or SAML providers like ADFS), I think when those are used, token authentication does not happen between the client application and the Portal but between the proxy and the Portal.&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt;Don’t get me wrong, the Portal only understands &amp;nbsp;‘tokeneze’ language when authenticating requests to secure items, however in the configuration above (just like when you use a web adaptor and IWA with ArcGIS Server), the proxy in front of your app (i.e. Web Adaptor) establishes the connection with the Portal using tokens while your user is authenticated at the proxy level say using IWA (this is also known as web tier authentication). So client app requests secure Portal content using the Web Adaptor URL, passing the user principal from AD. The WA authenticates with AD, then proxies the request to the Portal URL (switching port to 7443 and appending the admin token). No token is issued to your client.&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt;Long story short, for Enterprise Logins your python app does not need to pass a token or a user + pass. If things are configured correctly (i.e. Single Sign On works), the only thing needed is the URL parameter like this:&lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt;myGIS = GIS(url=‘myPortal.com/home’)&lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt;Hope that made sense.&lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt;In any case, with these things verify first, trust later. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt; &lt;/DIV&gt;&lt;DIV style="color: #333333;"&gt;...yes Esri listened this once. Also, they are&amp;nbsp;soon going to allow creating admin connections from Pro to AGS which is not currently possible and is a slap in the face for all customers that bought core-based AGS licenses. Progress of a kind.&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 23:20:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69604#M3328</guid>
      <dc:creator>GeofyAdmin</dc:creator>
      <dc:date>2018-09-12T23:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69605#M3329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;...and last note: Esri’s documentation makes it look like there is either built in or enterprise identity stores in Portal. In fact built in is always present. You can continue to keep a mix of users from each store (not much sense from a business perspective but technically possible). Built in users need to connect directly to Portal on port 7443 while enterprise users should go through the web adaptor for SSO.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Frankly Portal can pull users from three locations: built in, LDAP or SAML stores. All three can be operational at the same time.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Sep 2018 23:27:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69605#M3329</guid>
      <dc:creator>GeofyAdmin</dc:creator>
      <dc:date>2018-09-12T23:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can I use a token with ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69606#M3330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use this one&lt;/P&gt;&lt;DIV class="" style="color: #4c4c4c; background-color: #ffffff; border: thin solid transparent; padding: 0.5rem 0px;"&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;H3 style="font-size: 1.69949rem; margin: 0px 0px 0.75rem;"&gt;Obtaining a client id&lt;A class="" href="https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/#Obtaining-a-client-id" style="color: #0079c1; text-decoration: none; padding: 0px 1rem;"&gt;https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/#Obtaining-a-client-id&lt;/A&gt;&lt;/H3&gt;&lt;P style="margin-bottom: 1.5rem;"&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;/P&gt;&lt;UL style="font-size: 0.9375rem; margin-left: 0.75rem; margin-bottom: 1.5rem;"&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;Log into your web GIS (ArcGIS Online organization or ArcGIS Enterprise)&lt;/LI&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;Go to Content tab&lt;/LI&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;Click '+ Add Item &amp;gt; An Application' menu&lt;/LI&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;Add an application:&lt;UL style="font-size: 0.9375rem; margin-left: 0.75rem;"&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;Type: Application&lt;/LI&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;Title: Python&lt;/LI&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;Tags: python&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;On the Item details page of this newly created application, navigate to Settings tab&lt;/LI&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;Click the Registered Info button. It's towards the bottom of the page.&lt;/LI&gt;&lt;LI style="margin: 0.375rem 0px 0.375rem 1.5rem;"&gt;This will dispaly an App ID. This is your client id and needs to be passed in as the client_id parameter when construcing a GIS object. You need this in your Python code to log in.&lt;/LI&gt;&lt;/UL&gt;&lt;P style="margin-bottom: 1.5rem;"&gt;You can then log on to your org using the Python API using the code shown below:&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="" style="color: #4c4c4c; background-color: #ffffff; border: thin solid transparent; padding: 0.5rem 0px;"&gt;&lt;DIV class="" style="color: #005e95; border-top: 1px solid transparent; padding: 0.5rem;"&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P style="margin-bottom: 1.5rem;"&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;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;PRE style="color: #4c4c4c; background-color: #f7f7f7; border: none; font-size: 16px;"&gt;&lt;SPAN class=""&gt;gis&lt;/SPAN&gt; &lt;SPAN class="" style="color: #666666;"&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;GIS&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #ba2121;"&gt;"https://python.playground.esri.com/portal"&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;username&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #ba2121;"&gt;"arcgis_python"&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;password&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #ba2121;"&gt;"amazing_arcgis_123"&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;          &lt;SPAN class=""&gt;client_id&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #ba2121;"&gt;'f8cRxbP3NO8bf9ag'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;SPAN class="" style="color: #008000;"&gt;print&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #ba2121;"&gt;"Successfully logged in as: "&lt;/SPAN&gt; &lt;SPAN class="" style="color: #666666;"&gt;+&lt;/SPAN&gt; &lt;SPAN class=""&gt;gis&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;properties&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;user&lt;/SPAN&gt;&lt;SPAN class="" style="color: #666666;"&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;username&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/" title="https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/"&gt;Working with different authentication schemes | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jan 2020 12:50:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/can-i-use-a-token-with-arcgis-api-for-python/m-p/69606#M3330</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-01-20T12:50:25Z</dc:date>
    </item>
  </channel>
</rss>

