<?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: Non-interactive GIS connection for Arcgis Online with Python in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1555651#M10853</link>
    <description>&lt;P&gt;My solution to this issue is to create a new AGOL account using AGOL credentials, not organisation credentials.&amp;nbsp; Then the username/password method works fine.&amp;nbsp; The other methods all have limited functionality, as you've discovered.&lt;/P&gt;&lt;P&gt;NB:&amp;nbsp; To avoid having credentials hard-coded in your script, see:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/latest/guide/working-with-different-authentication-schemes/#storing-your-credentials-locally" target="_blank"&gt;Working with different authentication schemes | ArcGIS API for Python&lt;/A&gt;&lt;/P&gt;&lt;P&gt;(see the section, 'Storing your credentials locally')&lt;/P&gt;</description>
    <pubDate>Tue, 05 Nov 2024 23:37:32 GMT</pubDate>
    <dc:creator>NikSandsTP</dc:creator>
    <dc:date>2024-11-05T23:37:32Z</dc:date>
    <item>
      <title>Non-interactive GIS connection for Arcgis Online with Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1367312#M9487</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use Arcgis online with Python. I used to connect like this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;from arcgis.gis import GIS&lt;/P&gt;
&lt;P&gt;gis = GIS(username=XYZ, password=XYZ)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To connect to my Arcgis account, I now use OKTA, so I can no longer use the above method. I've tried using the portal url like this (non-interactive method):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;gis = GIS(url=”&lt;A href="https://lfdj.maps.arcgis.com" target="_blank" rel="noopener"&gt;https://XYZX.maps.arcgis.com&lt;/A&gt;”)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I have two problems:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;EM&gt;gis.users.me&lt;/EM&gt; : this command returns null, so I can no longer use &lt;EM&gt;gis.users.me.items&lt;/EM&gt;&lt;/LI&gt;
&lt;LI&gt;The following code generates a 'NoneType' object is not subscriptable error. The detailed error is shown below.&lt;/LI&gt;
&lt;/OL&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;item_properties = {'title': XYZ, 'snippet': XYZ, 'tags': XYZ}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;file = XYZ.csv&lt;/P&gt;
&lt;P&gt;gis.content.add(item_properties, data = file, folder = XYZ)&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you know how to connect properly with a non-interactive method and how to add files via this connection ? Thank you.&lt;/P&gt;
&lt;P&gt;The detailed error :&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;/opt/conda/lib/python3.9/site-packages/arcgis/gis/__init__.py in add(self, item_properties, data, thumbnail, metadata, owner, folder, item_id, **kwargs)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; 6835&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if "text" in kwargs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; 6836&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item_properties["text"] = kwargs.pop("text", None)&lt;/P&gt;
&lt;P&gt;-&amp;gt; 6837&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; itemid = self._portal.add_item(&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; 6838&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item_properties,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; 6839&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/opt/conda/lib/python3.9/site-packages/arcgis/gis/_impl/_portalpy.py in add_item(self, item_properties, data, thumbnail, metadata, owner, folder)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 423&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # If owner isn't specified, use the logged in user&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 424&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if not owner:&lt;/P&gt;
&lt;P&gt;--&amp;gt; 425&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; owner = self.logged_in_user()["username"]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 426&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;427&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Setup the item path, including the folder, and post to it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TypeError: 'NoneType' object is not subscriptable&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 15:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1367312#M9487</guid>
      <dc:creator>julian3930</dc:creator>
      <dc:date>2024-07-01T15:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Non-interactive GIS connection for Arcgis Online with Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1367361#M9490</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/625390"&gt;@julian3930&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;With SAML authentication, you won't be able to authenticate without user interaction.&amp;nbsp; One thing you could try is to create an Application in ArcGIS Online by going to New Item &amp;gt; Application:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JakeSkinner_0-1704725572011.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90831i6D6AF547B96B7C99/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JakeSkinner_0-1704725572011.png" alt="JakeSkinner_0-1704725572011.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Specify Other Application and then specify a name:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JakeSkinner_1-1704725596204.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90832iE642728FB21DB9D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JakeSkinner_1-1704725596204.png" alt="JakeSkinner_1-1704725596204.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In the Application details, this will create a Client ID and Client Secret:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JakeSkinner_2-1704725668545.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90833i5E839E391F6BDEA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JakeSkinner_2-1704725668545.png" alt="JakeSkinner_2-1704725668545.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Using these two, you can generate a token to authenticate with AGOL:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests, json
from arcgis.gis import GIS

# Variables
clientId = 'Gl2890aGas'
clientSecret = '123kl0987234jajfw9087f123r'

# Generate Token
params = {
    'client_id': clientId,
    'client_secret': clientSecret,
    'grant_type': "client_credentials",
}
request = requests.get('https://www.arcgis.com/sharing/oauth2/token', params=params)
response = request.json()
token = response["access_token"]

# Connect to GIS
gis = GIS('https://www.arcgis.com', token=token)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, you have very limited functionality when authenticating this way.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 14:57:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1367361#M9490</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2024-01-08T14:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Non-interactive GIS connection for Arcgis Online with Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1367811#M9495</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help. Unfortunately, this proposition doesn't work as well. When I use the exact same code changing id and client secret, I have the same error when I do gis.content.add. It seems that it is a problem of the logged user.&lt;/P&gt;&lt;P&gt;/opt/conda/lib/python3.9/site-packages/arcgis/gis/__init__.py in add(self, item_properties, data, thumbnail, metadata, owner, folder, item_id, **kwargs)&lt;BR /&gt;6835 if "text" in kwargs:&lt;BR /&gt;6836 item_properties["text"] = kwargs.pop("text", None)&lt;BR /&gt;-&amp;gt; 6837 itemid = self._portal.add_item(&lt;BR /&gt;6838 item_properties,&lt;BR /&gt;6839 data,&lt;/P&gt;&lt;P&gt;/opt/conda/lib/python3.9/site-packages/arcgis/gis/_impl/_portalpy.py in add_item(self, item_properties, data, thumbnail, metadata, owner, folder)&lt;BR /&gt;423 # If owner isn't specified, use the logged in user&lt;BR /&gt;424 if not owner:&lt;BR /&gt;--&amp;gt; 425 owner = self.logged_in_user()["username"]&lt;BR /&gt;426&lt;BR /&gt;427 # Setup the item path, including the folder, and post to it&lt;/P&gt;&lt;P&gt;TypeError: 'NoneType' object is not subscriptable&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 13:25:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1367811#M9495</guid>
      <dc:creator>julian3930</dc:creator>
      <dc:date>2024-01-09T13:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Non-interactive GIS connection for Arcgis Online with Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1555651#M10853</link>
      <description>&lt;P&gt;My solution to this issue is to create a new AGOL account using AGOL credentials, not organisation credentials.&amp;nbsp; Then the username/password method works fine.&amp;nbsp; The other methods all have limited functionality, as you've discovered.&lt;/P&gt;&lt;P&gt;NB:&amp;nbsp; To avoid having credentials hard-coded in your script, see:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/latest/guide/working-with-different-authentication-schemes/#storing-your-credentials-locally" target="_blank"&gt;Working with different authentication schemes | ArcGIS API for Python&lt;/A&gt;&lt;/P&gt;&lt;P&gt;(see the section, 'Storing your credentials locally')&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 23:37:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/non-interactive-gis-connection-for-arcgis-online/m-p/1555651#M10853</guid>
      <dc:creator>NikSandsTP</dc:creator>
      <dc:date>2024-11-05T23:37:32Z</dc:date>
    </item>
  </channel>
</rss>

