<?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 How to generate a valid token for ArcGIS Online Feature Service in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-generate-a-valid-token-for-arcgis-online/m-p/1061902#M3851</link>
    <description>&lt;P&gt;I'm trying to access admin APIs for my feature service, but I'm unable to get a valid token. I saw this post and followed along (&lt;A href="https://community.esri.com/t5/arcgis-rest-api-questions/generating-token-for-arcgis-online-hosted-service/m-p/220721" target="_blank"&gt;https://community.esri.com/t5/arcgis-rest-api-questions/generating-token-for-arcgis-online-hosted-service/m-p/220721&lt;/A&gt;) and I was able to generate a token. However, when I add that token into my URL to access the admin services, it says Invalid Token. Is there another way I should be generating this token to get the access I need?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;URL to generate token looks like this:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;https://www.arcgis.com/sharing/generateToken?f=json&amp;amp;username=USERNAME&amp;amp;password=PASSWORD&amp;amp;client=requestip&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;URL to try to access the feature service admin APIs looks like this:&lt;/STRONG&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;https://services6.arcgis.com/qDx.../arcgis/rest/admin/services/Layer_Name/FeatureServer?token=2nt...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-05-26 at 10.08.24 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/14221i75B1D93E2890FF29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2021-05-26 at 10.08.24 AM.png" alt="Screen Shot 2021-05-26 at 10.08.24 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 May 2021 17:09:25 GMT</pubDate>
    <dc:creator>MatthewFogarty</dc:creator>
    <dc:date>2021-05-26T17:09:25Z</dc:date>
    <item>
      <title>How to generate a valid token for ArcGIS Online Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-generate-a-valid-token-for-arcgis-online/m-p/1061902#M3851</link>
      <description>&lt;P&gt;I'm trying to access admin APIs for my feature service, but I'm unable to get a valid token. I saw this post and followed along (&lt;A href="https://community.esri.com/t5/arcgis-rest-api-questions/generating-token-for-arcgis-online-hosted-service/m-p/220721" target="_blank"&gt;https://community.esri.com/t5/arcgis-rest-api-questions/generating-token-for-arcgis-online-hosted-service/m-p/220721&lt;/A&gt;) and I was able to generate a token. However, when I add that token into my URL to access the admin services, it says Invalid Token. Is there another way I should be generating this token to get the access I need?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;URL to generate token looks like this:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;https://www.arcgis.com/sharing/generateToken?f=json&amp;amp;username=USERNAME&amp;amp;password=PASSWORD&amp;amp;client=requestip&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;URL to try to access the feature service admin APIs looks like this:&lt;/STRONG&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;https://services6.arcgis.com/qDx.../arcgis/rest/admin/services/Layer_Name/FeatureServer?token=2nt...&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-05-26 at 10.08.24 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/14221i75B1D93E2890FF29/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2021-05-26 at 10.08.24 AM.png" alt="Screen Shot 2021-05-26 at 10.08.24 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 17:09:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-generate-a-valid-token-for-arcgis-online/m-p/1061902#M3851</guid>
      <dc:creator>MatthewFogarty</dc:creator>
      <dc:date>2021-05-26T17:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a valid token for ArcGIS Online Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-generate-a-valid-token-for-arcgis-online/m-p/1062590#M3857</link>
      <description>&lt;P&gt;Hi Matthew,&lt;/P&gt;&lt;P&gt;There are &lt;A href="https://developers.arcgis.com/documentation/mapping-apis-and-services/security/" target="_blank" rel="noopener"&gt;lots of ways&lt;/A&gt; to generate a token for ArcGIS Online. My preferred way is using the &lt;A href="https://developers.arcgis.com/documentation/mapping-apis-and-services/security/application-credentials/" target="_blank" rel="noopener"&gt;application credentials&lt;/A&gt; for an item in my ArcGIS Online organization. The steps are:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Browse to the Content tab of your ArcGIS Online organization. Add Item -&amp;gt; An Application of the type "Application"&lt;/LI&gt;&lt;LI&gt;Go to the Item Details page of the created item and browse to the Settings tab. At the bottom of the page, expand "Registered Info". You should see an AppID and AppSecret.&lt;/LI&gt;&lt;LI&gt;Go to the Oauth2.0 token URL:&amp;nbsp;&lt;A href="https://www.arcgis.com/sharing/rest/oauth2/token?" target="_blank"&gt;https://www.arcgis.com/sharing/rest/oauth2/token?&lt;/A&gt;. The URL parameters we need are:&lt;/LI&gt;&lt;/OL&gt;&lt;UL&gt;&lt;LI&gt;f = json&lt;/LI&gt;&lt;LI&gt;client_id = your AppID from above&lt;/LI&gt;&lt;LI&gt;client_secret = your AppSecret from above&lt;/LI&gt;&lt;LI&gt;grant_type = client_credentials&lt;/LI&gt;&lt;LI&gt;expiration =&amp;nbsp;20160 (2 weeks in minutes, this is the maximum)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Send this as a GET or POST request, and a token should be returned&amp;nbsp; that can be used for all content owned by/shared with you to in your ArcGIS Online organization.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;&lt;P&gt;-Calvin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 21:40:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-generate-a-valid-token-for-arcgis-online/m-p/1062590#M3857</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-05-27T21:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a valid token for ArcGIS Online Feature Service</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-generate-a-valid-token-for-arcgis-online/m-p/1069131#M3884</link>
      <description>&lt;P&gt;I do this with RestSharp. Instead of appending the token onto the end of your request URL, you add the token to the request using the AddHeader method.&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;LI-CODE lang="csharp"&gt; var client = new RestClient(baseUrl); //the url of your service
            var request = new RestRequest("0/applyEdits", Method.POST);
            request.AddHeader("Authorization", $"Bearer {token}"); //"token" is a parameter passed into the method; I left the method signature off this sample
            request.AddParameter("f", "json");
            request.AddParameter(editsType.ToString(), jsonAdds); //"jsonAdds" is another parameter of type JSON object
            if (editsType == applyEditsType.adds) //"editsType" is a custom enum parameter
            {//allows service to create new GlobalID for adds
                request.AddParameter("useGlobalIds", "false");
            }
            else
            {//allows updates and deletes to look for records based on GlobalID instead of OBJECTID
                request.AddParameter("useGlobalIds", "true");
            }
            var response = client.Execute(request);
            if (response.ErrorException != null)
            {
                var gisException = new Exception("Error retrieving response.  Check inner details for more info.", response.ErrorException);
                throw gisException;
            }
            return response.Content;&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 16 Jun 2021 21:47:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/how-to-generate-a-valid-token-for-arcgis-online/m-p/1069131#M3884</guid>
      <dc:creator>BethLott</dc:creator>
      <dc:date>2021-06-16T21:47:16Z</dc:date>
    </item>
  </channel>
</rss>

