<?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: Excel vba request a token from Rest API appears to be 106 characters shorter than token generated by arcgis online query tools in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/excel-vba-request-a-token-from-rest-api-appears-to/m-p/1480494#M4755</link>
    <description>&lt;P&gt;I was having the same issue until I changed the referer to the https of my feature service.&lt;/P&gt;&lt;P&gt;I also downloaded the module for parsing the json at:&amp;nbsp;&lt;A href="https://github.com/VBA-tools/VBA-JSON" target="_blank"&gt;https://github.com/VBA-tools/VBA-JSON&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here is the function that works for me:&lt;/P&gt;&lt;P&gt;Public Function getToken()&lt;BR /&gt;Dim httpReq As Object&lt;BR /&gt;Dim response As String&lt;BR /&gt;Dim USERNAME, PASSWORD&lt;BR /&gt;Dim tkn As Variant&lt;BR /&gt;Dim myFeature&lt;/P&gt;&lt;P&gt;USERNAME = "xxxxx"&lt;BR /&gt;PASSWORD = "xxxxx"&lt;BR /&gt;myFeature = "&lt;A href="https://services.arcgis.com/xxxxxxxx/arcgis/rest/services/xxxxx/FeatureServer" target="_blank"&gt;https://services.arcgis.com/xxxxxxxx/arcgis/rest/services/xxxxx/FeatureServer&lt;/A&gt;"&lt;BR /&gt;Set httpReq = CreateObject("MSXML2.ServerXMLHTTP")&lt;/P&gt;&lt;P&gt;httpReq.Open "GET", "&lt;A href="https://www.arcgis.com/sharing/generateToken?f=pjson&amp;amp;username=" target="_blank"&gt;https://www.arcgis.com/sharing/generateToken?f=pjson&amp;amp;username=&lt;/A&gt;" &amp;amp; USERNAME &amp;amp; "&amp;amp;password=" &amp;amp; PASSWORD &amp;amp; "&amp;amp;client=&amp;amp;ip=&amp;amp;referer=" * myFeature &amp;amp; "&amp;amp;expiration=1"&lt;BR /&gt;httpReq.send&lt;BR /&gt;response = httpReq.responseText&lt;BR /&gt;Set JSON = JsonConverter.ParseJson(response)&lt;BR /&gt;'Debug.Print httpReq.responseText&lt;/P&gt;&lt;P&gt;tkn = JSON("token")&lt;/P&gt;&lt;P&gt;getToken = tkn&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;</description>
    <pubDate>Wed, 29 May 2024 19:40:49 GMT</pubDate>
    <dc:creator>ReubenWolff</dc:creator>
    <dc:date>2024-05-29T19:40:49Z</dc:date>
    <item>
      <title>Excel vba request a token from Rest API appears to be 106 characters shorter than token generated by arcgis online query tools</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/excel-vba-request-a-token-from-rest-api-appears-to/m-p/482548#M2317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying create a VBA tool in Excel to insert data into a AGOL Feature layer. When I request a token via VBA it ends with .. and is 106 characters shorter than the token generated by the AGOL query tool. when I try to use the token I request I get and "invalid token" error. But if I copy the AGOL generated token and paste it into my code my query works fine. It looks like the VBA requested token is cut off.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone else run into this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Larry&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A snippet of my code:&lt;/P&gt;&lt;P&gt;Dim tokenHTTP As Object&lt;BR /&gt; Set tokenHTTP = CreateObject("MSXML2.ServerXMLHTTP")&lt;BR /&gt; Dim tokenJSON As String&lt;BR /&gt; Dim tokenURL As String&lt;BR /&gt;tokenURL = "https://www.arcgis.com/sharing/rest/generateToken?f=json&amp;amp;username=MyuserName&amp;amp;password=MyPassword&amp;amp;client=requestip&amp;amp;expiration=1"&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt; tokenHTTP.Open "POST", tokenURL, False&lt;BR /&gt; tokenHTTP.setRequestHeader "Content-type", "application/json"&lt;BR /&gt; tokenHTTP.send (tokenJSON)&lt;BR /&gt; &lt;BR /&gt; Debug.Print tokenHTTP.responseText&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Aug 2019 20:39:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/excel-vba-request-a-token-from-rest-api-appears-to/m-p/482548#M2317</guid>
      <dc:creator>Larry</dc:creator>
      <dc:date>2019-08-20T20:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Excel vba request a token from Rest API appears to be 106 characters shorter than token generated by arcgis online query tools</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/excel-vba-request-a-token-from-rest-api-appears-to/m-p/1480494#M4755</link>
      <description>&lt;P&gt;I was having the same issue until I changed the referer to the https of my feature service.&lt;/P&gt;&lt;P&gt;I also downloaded the module for parsing the json at:&amp;nbsp;&lt;A href="https://github.com/VBA-tools/VBA-JSON" target="_blank"&gt;https://github.com/VBA-tools/VBA-JSON&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Here is the function that works for me:&lt;/P&gt;&lt;P&gt;Public Function getToken()&lt;BR /&gt;Dim httpReq As Object&lt;BR /&gt;Dim response As String&lt;BR /&gt;Dim USERNAME, PASSWORD&lt;BR /&gt;Dim tkn As Variant&lt;BR /&gt;Dim myFeature&lt;/P&gt;&lt;P&gt;USERNAME = "xxxxx"&lt;BR /&gt;PASSWORD = "xxxxx"&lt;BR /&gt;myFeature = "&lt;A href="https://services.arcgis.com/xxxxxxxx/arcgis/rest/services/xxxxx/FeatureServer" target="_blank"&gt;https://services.arcgis.com/xxxxxxxx/arcgis/rest/services/xxxxx/FeatureServer&lt;/A&gt;"&lt;BR /&gt;Set httpReq = CreateObject("MSXML2.ServerXMLHTTP")&lt;/P&gt;&lt;P&gt;httpReq.Open "GET", "&lt;A href="https://www.arcgis.com/sharing/generateToken?f=pjson&amp;amp;username=" target="_blank"&gt;https://www.arcgis.com/sharing/generateToken?f=pjson&amp;amp;username=&lt;/A&gt;" &amp;amp; USERNAME &amp;amp; "&amp;amp;password=" &amp;amp; PASSWORD &amp;amp; "&amp;amp;client=&amp;amp;ip=&amp;amp;referer=" * myFeature &amp;amp; "&amp;amp;expiration=1"&lt;BR /&gt;httpReq.send&lt;BR /&gt;response = httpReq.responseText&lt;BR /&gt;Set JSON = JsonConverter.ParseJson(response)&lt;BR /&gt;'Debug.Print httpReq.responseText&lt;/P&gt;&lt;P&gt;tkn = JSON("token")&lt;/P&gt;&lt;P&gt;getToken = tkn&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2024 19:40:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/excel-vba-request-a-token-from-rest-api-appears-to/m-p/1480494#M4755</guid>
      <dc:creator>ReubenWolff</dc:creator>
      <dc:date>2024-05-29T19:40:49Z</dc:date>
    </item>
    <item>
      <title>Re: Excel vba request a token from Rest API appears to be 106 characters shorter than token generated by arcgis online query tools</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/excel-vba-request-a-token-from-rest-api-appears-to/m-p/1480660#M4758</link>
      <description>&lt;P&gt;Corrected vba. I had an asterisk instead of an ampersand:&lt;/P&gt;&lt;P&gt;Here is the corrected function:&lt;/P&gt;&lt;P&gt;Public Function getToken()&lt;BR /&gt;Dim httpReq As Object&lt;BR /&gt;Dim response As String&lt;BR /&gt;Dim USERNAME, PASSWORD&lt;BR /&gt;Dim tkn As Variant&lt;BR /&gt;Dim myFeature&lt;/P&gt;&lt;P&gt;USERNAME = "xxxxx"&lt;BR /&gt;PASSWORD = "xxxxx"&lt;BR /&gt;myFeature = "&lt;A href="https://services.arcgis.com/xxxxxxxx/arcgis/rest/services/xxxxx/FeatureServer" target="_blank"&gt;https://services.arcgis.com/xxxxxxxx/arcgis/rest/services/xxxxx/FeatureServer&lt;/A&gt;"&lt;BR /&gt;Set httpReq = CreateObject("MSXML2.ServerXMLHTTP")&lt;/P&gt;&lt;P&gt;httpReq.Open "GET", "&lt;A href="https://www.arcgis.com/sharing/generateToken?f=pjson&amp;amp;username=" target="_blank"&gt;https://www.arcgis.com/sharing/generateToken?f=pjson&amp;amp;username=&lt;/A&gt;" &amp;amp; USERNAME &amp;amp; "&amp;amp;password=" &amp;amp; PASSWORD &amp;amp; "&amp;amp;client=&amp;amp;ip=&amp;amp;referer=" &amp;amp; myFeature &amp;amp; "&amp;amp;expiration=1"&lt;BR /&gt;httpReq.send&lt;BR /&gt;response = httpReq.responseText&lt;BR /&gt;Set JSON = JsonConverter.ParseJson(response)&lt;BR /&gt;'Debug.Print httpReq.responseText&lt;/P&gt;&lt;P&gt;tkn = JSON("token")&lt;/P&gt;&lt;P&gt;getToken = tkn&lt;/P&gt;&lt;P&gt;End Function&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 01:03:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/excel-vba-request-a-token-from-rest-api-appears-to/m-p/1480660#M4758</guid>
      <dc:creator>ReubenWolff</dc:creator>
      <dc:date>2024-05-30T01:03:22Z</dc:date>
    </item>
  </channel>
</rss>

