<?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: POST Token returns &amp;quot;Process finished with exit code 0&amp;quot; in ArcGIS REST APIs and Services Questions</title>
    <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005511#M3619</link>
    <description>&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;I am getting a HTTP:400 error now, stating that the &lt;STRONG&gt;client_id&lt;/STRONG&gt; is not specified??&lt;/P&gt;&lt;P&gt;I have hardcoded the&amp;nbsp; &lt;STRONG&gt;client/client_id/referer&lt;/STRONG&gt; as company name and/or the base URL. But still keep getting the&amp;nbsp;'&lt;STRONG&gt;client_id&lt;/STRONG&gt;&amp;nbsp;'not specified' error message??&lt;/P&gt;&lt;P&gt;Odd.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Clive&lt;/P&gt;</description>
    <pubDate>Mon, 30 Nov 2020 14:27:58 GMT</pubDate>
    <dc:creator>CliveSwan</dc:creator>
    <dc:date>2020-11-30T14:27:58Z</dc:date>
    <item>
      <title>POST Token returns "Process finished with exit code 0"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005459#M3617</link>
      <description>&lt;P&gt;Greetings&lt;/P&gt;&lt;P&gt;I am working on an ESRI Hosted site.&lt;/P&gt;&lt;P&gt;I am trying to automate the ESRI token web page Generate Token form ie:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="GenerateToken.PNG" style="width: 602px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/1167i8D0AC34DBEDE8B46/image-size/large?v=v2&amp;amp;px=999" role="button" title="GenerateToken.PNG" alt="GenerateToken.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used a Python POST:&lt;/P&gt;&lt;PRE&gt;user_name  = &lt;SPAN&gt;'me'&lt;BR /&gt;&lt;/SPAN&gt;pass_word  = &lt;SPAN&gt;'my password'&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;referer = &lt;SPAN&gt;'https://company.cloud.esriuk.com'&lt;BR /&gt;&lt;/SPAN&gt;referer_name = &lt;SPAN&gt;'https://company.cloud.esriuk.com/portal/sharing/rest/generateToken'&lt;BR /&gt;&lt;/SPAN&gt;token = &lt;SPAN&gt;''&lt;BR /&gt;&lt;/SPAN&gt;expires    =  &lt;SPAN&gt;90&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;##data = {username=user_name,password=pass_word, client=referer, referer=url, expiration=90, f=json}&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;requests.post(&lt;SPAN&gt;user&lt;/SPAN&gt;=user_name, &lt;SPAN&gt;password&lt;/SPAN&gt;=pass_word, &lt;SPAN&gt;client&lt;/SPAN&gt;=referer, &lt;SPAN&gt;referer&lt;/SPAN&gt;=referer_name, &lt;SPAN&gt;expiration&lt;/SPAN&gt;=&lt;SPAN&gt;90&lt;/SPAN&gt;, &lt;SPAN&gt;f&lt;/SPAN&gt;=json)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"Generating token"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;I also tried:&lt;/PRE&gt;&lt;PRE&gt;gis_server = GIS(&lt;SPAN&gt;url&lt;/SPAN&gt;=&lt;SPAN&gt;f"server_base_url/web_adaptor/admin"&lt;/SPAN&gt;,&lt;BR /&gt;                    &lt;SPAN&gt;token_url&lt;/SPAN&gt;=&lt;SPAN&gt;f"server_base_url/web_adaptor/tokens/generateToken"&lt;/SPAN&gt;,&lt;BR /&gt;                    &lt;SPAN&gt;username&lt;/SPAN&gt;=&lt;SPAN&gt;"admin_user"&lt;/SPAN&gt;,&lt;BR /&gt;                    &lt;SPAN&gt;password&lt;/SPAN&gt;=&lt;SPAN&gt;"admin_password"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(token)&lt;/PRE&gt;&lt;PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I just get the process finished, no output??&lt;BR /&gt;Any suggestions?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Clive&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 11:35:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005459#M3617</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2020-11-30T11:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: POST Token returns "Process finished with exit code 0"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005468#M3618</link>
      <description>&lt;LI-CODE lang="python"&gt;import requests


portalUrl = "https://domain/portal"
username = 'username'
password = "password"


def generateToken(username, password, portalUrl):
    # Retrieves a token to be used with API requests.
    headers = {'content-type': 'application/x-www-form-urlencoded'}
    parameters = {'username': username,
                  'password': password,
                  'client': 'referer',
                  'referer': portalUrl,
                  'expiration': 60,
                  'f': 'json'}
    url = portalUrl + '/sharing/rest/generateToken?'
    response = requests.post(url, data=parameters, headers=headers)

    try:
        jsonResponse = response.json()
        
        if 'token' in jsonResponse:
            return jsonResponse['token']
        elif 'error' in jsonResponse:
            print (jsonResponse['error']['message'])
            for detail in jsonResponse['error']['details']:
                print (detail)
    except ValueError:
        print('An unspecified error occurred.')
        print(ValueError)


        
token = generateToken(username, password, portalUrl)
print(token)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Nov 2020 12:07:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005468#M3618</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-11-30T12:07:19Z</dc:date>
    </item>
    <item>
      <title>Re: POST Token returns "Process finished with exit code 0"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005511#M3619</link>
      <description>&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;I am getting a HTTP:400 error now, stating that the &lt;STRONG&gt;client_id&lt;/STRONG&gt; is not specified??&lt;/P&gt;&lt;P&gt;I have hardcoded the&amp;nbsp; &lt;STRONG&gt;client/client_id/referer&lt;/STRONG&gt; as company name and/or the base URL. But still keep getting the&amp;nbsp;'&lt;STRONG&gt;client_id&lt;/STRONG&gt;&amp;nbsp;'not specified' error message??&lt;/P&gt;&lt;P&gt;Odd.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Clive&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 14:27:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005511#M3619</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2020-11-30T14:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: POST Token returns "Process finished with exit code 0"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005519#M3620</link>
      <description>&lt;P&gt;I'm not sure what you mean exactly, you shouldn't need to modify anything within the generate token function itself.&lt;/P&gt;&lt;P&gt;I'm guessing you have the esri arcgis GIS module in your library?&amp;nbsp; You could:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS

#params
portal_url = "https://domain/portal"
username = "me"
password = "P@ssword123"

#do stuff
connection = GIS(portal_url, username, password)
token = connection._con.token
print(token)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 14:45:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005519#M3620</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-11-30T14:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: POST Token returns "Process finished with exit code 0"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005536#M3621</link>
      <description>&lt;P&gt;Since client/client_id/referer are not the same thing, can you share your code again?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 15:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005536#M3621</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-11-30T15:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: POST Token returns "Process finished with exit code 0"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005547#M3622</link>
      <description>&lt;P&gt;Hi Joshua,&lt;/P&gt;&lt;PRE&gt;The client is a Webapp URL: https://company.cloud.esriuk.com/&lt;BR /&gt;&lt;BR /&gt;The code is:&lt;BR /&gt;######&lt;BR /&gt;username  = &lt;SPAN&gt;'me'&lt;BR /&gt;&lt;/SPAN&gt;password  = &lt;SPAN&gt;'my password&lt;BR /&gt;&lt;/SPAN&gt;referer = &lt;SPAN&gt;"https://company.maps.arcgis.com"&lt;BR /&gt;&lt;/SPAN&gt;portalUrl = &lt;SPAN&gt;"https://company.cloud.esriuk.com/portal"&lt;BR /&gt;&lt;/SPAN&gt;tokenURL = &lt;SPAN&gt;"https://company.cloud.esriuk.com/portal/sharing/rest/generateToken"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"START Generate Token"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;&lt;SPAN&gt;generateToken&lt;/SPAN&gt;(&lt;SPAN&gt;user_name&lt;/SPAN&gt;, &lt;SPAN&gt;pass_word&lt;/SPAN&gt;, portalUrl):&lt;BR /&gt;    &lt;SPAN&gt;# Retrieves a token to be used with API requests.&lt;BR /&gt;&lt;/SPAN&gt;    headers = {&lt;SPAN&gt;'content-type'&lt;/SPAN&gt;: &lt;SPAN&gt;'application/x-www-form-urlencoded'&lt;/SPAN&gt;}&lt;BR /&gt;    parameters = {&lt;SPAN&gt;'username'&lt;/SPAN&gt;: username, &lt;SPAN&gt;'password'&lt;/SPAN&gt;: password, &lt;SPAN&gt;'client'&lt;/SPAN&gt;: &lt;SPAN&gt;'referer'&lt;/SPAN&gt;, &lt;SPAN&gt;'referer'&lt;/SPAN&gt;: portalUrl, &lt;SPAN&gt;'expiration'&lt;/SPAN&gt;: &lt;SPAN&gt;60&lt;/SPAN&gt;, &lt;SPAN&gt;'f'&lt;/SPAN&gt;: &lt;SPAN&gt;'json'&lt;/SPAN&gt;}&lt;BR /&gt;    url = &lt;SPAN&gt;'https://eiffagekier.maps.arcgis.com/sharing/rest/oauth2/token'&lt;BR /&gt;&lt;/SPAN&gt;    response = requests.post(url, &lt;SPAN&gt;data&lt;/SPAN&gt;=parameters, &lt;SPAN&gt;headers&lt;/SPAN&gt;=headers)&lt;BR /&gt;    &lt;SPAN&gt;#print(response) ### &amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;    ### GET error&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;try&lt;/SPAN&gt;:&lt;BR /&gt;        jsonResponse = response.json()&lt;BR /&gt;        &lt;SPAN&gt;print&lt;/SPAN&gt;(jsonResponse)&lt;BR /&gt;&lt;BR /&gt;        &lt;SPAN&gt;if &lt;/SPAN&gt;&lt;SPAN&gt;'token' &lt;/SPAN&gt;&lt;SPAN&gt;in &lt;/SPAN&gt;jsonResponse:&lt;BR /&gt;            &lt;SPAN&gt;return &lt;/SPAN&gt;jsonResponse[&lt;SPAN&gt;'token'&lt;/SPAN&gt;]&lt;BR /&gt;        &lt;SPAN&gt;elif &lt;/SPAN&gt;&lt;SPAN&gt;'error' &lt;/SPAN&gt;&lt;SPAN&gt;in &lt;/SPAN&gt;jsonResponse:&lt;BR /&gt;            &lt;SPAN&gt;print &lt;/SPAN&gt;(jsonResponse[&lt;SPAN&gt;'error'&lt;/SPAN&gt;][&lt;SPAN&gt;'message'&lt;/SPAN&gt;])&lt;BR /&gt;            &lt;SPAN&gt;for &lt;/SPAN&gt;detail &lt;SPAN&gt;in &lt;/SPAN&gt;jsonResponse[&lt;SPAN&gt;'error'&lt;/SPAN&gt;][&lt;SPAN&gt;'details'&lt;/SPAN&gt;]:&lt;BR /&gt;                &lt;SPAN&gt;print &lt;/SPAN&gt;(detail)&lt;BR /&gt;    &lt;SPAN&gt;except &lt;/SPAN&gt;&lt;SPAN&gt;ValueError&lt;/SPAN&gt;:&lt;BR /&gt;        &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;'An Error occurred.'&lt;/SPAN&gt;)&lt;BR /&gt;        &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;ValueError&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;token = generateToken(username, password, tokenURL)    &lt;SPAN&gt;#### portalUrl&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(token)&lt;BR /&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"END Generate Token"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Clive&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 16:26:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005547#M3622</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2020-11-30T16:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: POST Token returns "Process finished with exit code 0"</title>
      <link>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005565#M3623</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I found this link that solves the problem. Short simple and does what needs to be done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/accessing-arcgis-online-services/" target="_blank"&gt;https://developers.arcgis.com/documentation/core-concepts/security-and-authentication/accessing-arcgis-online-services/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 17:13:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/post-token-returns-quot-process-finished-with-exit/m-p/1005565#M3623</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2020-11-30T17:13:02Z</dc:date>
    </item>
  </channel>
</rss>

