<?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: arcpy.SignInToPortal token expires after 12 hours in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1068340#M6201</link>
    <description>&lt;P&gt;Thanks Gintautas.&amp;nbsp; This was the approach went with ... just checking the token hadn't expired before I needed it again.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;</description>
    <pubDate>Tue, 15 Jun 2021 12:16:50 GMT</pubDate>
    <dc:creator>NeilEtheridge</dc:creator>
    <dc:date>2021-06-15T12:16:50Z</dc:date>
    <item>
      <title>arcpy.SignInToPortal token expires after 12 hours</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1066329#M6177</link>
      <description>&lt;P&gt;I have a script that runs for a long time (2 days) for deploying a large Utility Network.&amp;nbsp; The script makes a connection to portal early on using the SignInToPortal function, however by the time subsequent commands are run I get a ...&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Error: ERROR 002119: Must be connected and signed into the portal.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Failed to execute (AssetPackageToUtilityNetwork).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;I checked the token returned by SignInToPortal and it expires 12 hours after the request.&amp;nbsp; Using Fidder to capture the request I can see "expiration" is part of the request.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;/portal/sharing/rest/generateToken/username=utilitynetworkowner&amp;amp;password=abcdefg&amp;amp;&lt;STRONG&gt;expiration=720&lt;/STRONG&gt;&amp;amp;client=referer&amp;amp;referer=&lt;A href="http://www.esri.com/AGO/B90FF998-17C8-4248-8F0A-A7000000000" target="_blank"&gt;http://www.esri.com/AGO/B90FF998-17C8-4248-8F0A-A7000000000&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Is there anyway to change the timeout request?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 12:59:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1066329#M6177</guid>
      <dc:creator>NeilEtheridge</dc:creator>
      <dc:date>2021-06-09T12:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SignInToPortal token expires after 12 hours</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1066353#M6178</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/121411"&gt;@NeilEtheridge&lt;/a&gt;&amp;nbsp; you could generate the token with the below code, which includes the expiration parameter.&amp;nbsp; This value is in minutes, and the max is 15 days:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests, json

# Disable warnings
requests.packages.urllib3.disable_warnings()

username = "portaladmin"
password = "********"

tokenURL = 'https://portal.esri.com:7443/arcgis/sharing/rest/generateToken/'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'https://portal.esri.com', 'expiration': 21600}

r = requests.post(tokenURL, data = params, verify=False)
response = json.loads(r.content)
token = response['token']
print(token)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 09 Jun 2021 13:40:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1066353#M6178</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-06-09T13:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SignInToPortal token expires after 12 hours</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1066759#M6181</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In one of my projects I refresh token (if needed) before using token in some operation. I do it a little bit earlier than token expires.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 06:07:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1066759#M6181</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2021-06-10T06:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SignInToPortal token expires after 12 hours</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1068338#M6200</link>
      <description>&lt;P&gt;Thanks Jake for the reply - I should have thought to try it this way as I already do similar in other scripts when making direct calls to the REST interface.&amp;nbsp; I wasn't sure if subsequent Utility Network commands would recognise this token so went with the down the same track as Gintautas has suggested below.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 12:14:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1068338#M6200</guid>
      <dc:creator>NeilEtheridge</dc:creator>
      <dc:date>2021-06-15T12:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SignInToPortal token expires after 12 hours</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1068340#M6201</link>
      <description>&lt;P&gt;Thanks Gintautas.&amp;nbsp; This was the approach went with ... just checking the token hadn't expired before I needed it again.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Neil&lt;/P&gt;</description>
      <pubDate>Tue, 15 Jun 2021 12:16:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1068340#M6201</guid>
      <dc:creator>NeilEtheridge</dc:creator>
      <dc:date>2021-06-15T12:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.SignInToPortal token expires after 12 hours</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1396100#M9764</link>
      <description>&lt;P&gt;Jake,&lt;/P&gt;&lt;P&gt;Is connecting to AGOL a similar process? I've got a code that is iteratively exporting each Hosted Feature Service in the organization to FGDB, but it tends to hand up after a couple hours. I'm doing a simple&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis = GIS(portalURL, portalUser, portalPass)&lt;/LI-CODE&gt;&lt;P&gt;to access the AGOL org. Does that generate a token with a time limit? If so, any way to tell how long that time limit is (or to change it)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 17:10:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcpy-signintoportal-token-expires-after-12-hours/m-p/1396100#M9764</guid>
      <dc:creator>ThomasM</dc:creator>
      <dc:date>2024-03-14T17:10:10Z</dc:date>
    </item>
  </channel>
</rss>

