<?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 oauth2 token give only access to public content of my organization in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/oauth2-token-give-only-access-to-public-content-of/m-p/1253798#M8335</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to use oauth2 with python in order to get a token that will allow me to query content in my organization with the arcgis library. Everything works correctly, except the fact that when I sign in to ArcGIS Online with the oauth2 token, I only have access to the public items.&lt;BR /&gt;&lt;BR /&gt;I am administrator in my organization and I have created my oauth2 application in developers.arcgis.com&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MaximeDemers_0-1675177698173.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61721i4D94EFFF902429D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MaximeDemers_0-1675177698173.png" alt="MaximeDemers_0-1675177698173.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In python I am using the following code to get a token using the clientId and clientSecret&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import request
import arcgis

def get_client_oauth2_token(portal_url, client_id, client_secret):
    url = "{}/sharing/rest/oauth2/token".format(portal_url)
    params = {
        'client_id': client_id,
        'grant_type': "client_credentials",
        'client_secret': client_secret
    }
    r = requests.post(url, params=params, verify=True)
    return r.json()

token = get_client_oauth2_token("https://www.arcgis.com", "my_client_id", "my_client_secret")["access_token"]

gis = arcgis.gis.GIS("https://www.arcgis.com", token=token, referer="https")
items = gis.content.search("", item_type="Map Service", max_items=100)
for item in items:
    print("{} - {}".format(item.id, item.access))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only public items are returned. I dont receive any error.&lt;/P&gt;&lt;P&gt;What is wrong with my oauth2 authentification here?&lt;BR /&gt;&lt;BR /&gt;Thank you for your help!&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2023 14:06:48 GMT</pubDate>
    <dc:creator>MaximeDemers</dc:creator>
    <dc:date>2023-02-01T14:06:48Z</dc:date>
    <item>
      <title>oauth2 token give only access to public content of my organization</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/oauth2-token-give-only-access-to-public-content-of/m-p/1253798#M8335</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to use oauth2 with python in order to get a token that will allow me to query content in my organization with the arcgis library. Everything works correctly, except the fact that when I sign in to ArcGIS Online with the oauth2 token, I only have access to the public items.&lt;BR /&gt;&lt;BR /&gt;I am administrator in my organization and I have created my oauth2 application in developers.arcgis.com&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MaximeDemers_0-1675177698173.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/61721i4D94EFFF902429D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MaximeDemers_0-1675177698173.png" alt="MaximeDemers_0-1675177698173.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In python I am using the following code to get a token using the clientId and clientSecret&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import request
import arcgis

def get_client_oauth2_token(portal_url, client_id, client_secret):
    url = "{}/sharing/rest/oauth2/token".format(portal_url)
    params = {
        'client_id': client_id,
        'grant_type': "client_credentials",
        'client_secret': client_secret
    }
    r = requests.post(url, params=params, verify=True)
    return r.json()

token = get_client_oauth2_token("https://www.arcgis.com", "my_client_id", "my_client_secret")["access_token"]

gis = arcgis.gis.GIS("https://www.arcgis.com", token=token, referer="https")
items = gis.content.search("", item_type="Map Service", max_items=100)
for item in items:
    print("{} - {}".format(item.id, item.access))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only public items are returned. I dont receive any error.&lt;/P&gt;&lt;P&gt;What is wrong with my oauth2 authentification here?&lt;BR /&gt;&lt;BR /&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 14:06:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/oauth2-token-give-only-access-to-public-content-of/m-p/1253798#M8335</guid>
      <dc:creator>MaximeDemers</dc:creator>
      <dc:date>2023-02-01T14:06:48Z</dc:date>
    </item>
  </channel>
</rss>

