Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection using GIS("Pro") intermittently fails when running script #1752

Open
mappybird opened this issue Jan 31, 2024 · 8 comments
Open
Labels

Comments

@mappybird
Copy link

Describe the bug
Connection using GIS("Pro") intermittently fails when running script

To Reproduce
from arcgis.gis import GIS
gis = GIS("Pro")

for loop in loops:
Run loop to do something big

Screenshots
authentication_pro

Expected behavior
Script runs without authentication error

Platform (please complete the following information):

  • Windows 10
  • Python API Version 2.1.0.3

Additional context
Just to be clear, this error happens intermittently when using the GIS("pro") method of connecting to ArcGIS Python API. There is also no traceback I can provide as it only outputs the error message above but still continues to run the loop (with more failures due to the GIS not being available anymore).

I can confirm that I'm logged into ArcGIS Pro when running the script and the Active portal is set. It's just odd that it happens intermittently and I was wondering how GIS("Pro") actually authenticates? Is it a matter of expired token and it fails to renew it?

@mappybird mappybird added the bug label Jan 31, 2024
@nanaeaubry
Copy link
Contributor

@mappybird
Pro credentials time out every so many days.
It depends how frequently your script is run and how often you get the error?
Not sure on the exact number of days but I can find out if it helps

@mappybird
Copy link
Author

@nanaeaubry
Thanks for following up, I use a fresh login to ArcGIS Pro everytime I run the script and I run it manually at the moment, not as a scheduled task.

The script runs fine initially in a loop but it will randomly error out with the authentication error after a while.

I am able to sometimes able to complete running the script with no errors. Worth noting that if I run it using a built-in account, the error does not appear.

I also tried to rule out network issues by running the script on a machine on a different network but the error still persists.

FYI, the script I'm running generates offline managed areas

@nanaeaubry
Copy link
Contributor

@mappybird
The login type might affect the longevity of the token. I found this : https://enterprise.arcgis.com/en/portal/latest/administer/windows/specify-the-default-token-expiration-time.htm

You can try to edit the token expiration time to see if it makes a difference? Creating these offline managed areas take a while depending on size so maybe you are running into this issue?

I can reach out to others and see if someone knows more about this behavior

@achapkowski
Copy link
Contributor

@nanaeaubry Thanks for following up, I use a fresh login to ArcGIS Pro everytime I run the script and I run it manually at the moment, not as a scheduled task.

The script runs fine initially in a loop but it will randomly error out with the authentication error after a while.

I am able to sometimes able to complete running the script with no errors. Worth noting that if I run it using a built-in account, the error does not appear.

I also tried to rule out network issues by running the script on a machine on a different network but the error still persists.

FYI, the script I'm running generates offline managed areas

What form of security are you see this time out?
To manage offline areas, you have to the owner of that Item. Administrator's can't manage other people's offline areas.

@mappybird
Copy link
Author

@nanaeaubry

I can try extending the token time in Portal, I thought the GIS('Pro') authentication method would've handled the negotiation for a token refresh when it returns an expired token but I'm unsure of the actual mechanism.

Like I mentioned above, absolutely no issues when I use a built-in account.

@achapkowski
I'm using SAML to authenticate in Pro.

I am the owner of the WebMap Item and I am able to generate offline areas partially depending on when the authentication 'times out'. It's kind of a dice roll to be honest.

@achapkowski
Copy link
Contributor

@nanaeaubry

I can try extending the token time in Portal, I thought the GIS('Pro') authentication method would've handled the negotiation for a token refresh when it returns an expired token but I'm unsure of the actual mechanism.

Like I mentioned above, absolutely no issues when I use a built-in account.

@achapkowski I'm using SAML to authenticate in Pro.

I am the owner of the WebMap Item and I am able to generate offline areas partially depending on when the authentication 'times out'. It's kind of a dice roll to be honest.

@mappybird the issue is most likely with ArcGIS Pro and when it expires it's credentials. You can try using the arcpy method Signin to Portal method and pass your credentials at the top of your script.

https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/signintoportal.htm

@mappybird
Copy link
Author

@achapkowski

The SignInToPortal method does not support SAML(or interactive logins).

Am I out of luck here?

@mappybird
Copy link
Author

I've done some further testing and and got an update:

Using the following authentication method with a built-in account, it works without any issues :
gis = GIS("https://portalname.domain.com/webadapter_name", "sharinguser", "password")

However, when the GIS('Pro') method of authentication was used, it errors outs with the following message regardless if you use a built-in account or SAML ( I initially thought built in might work but still failed when I attempted to run the script):

A general error occurred: Could not login using Pro authencation. Please verify in Pro that you are logged in.

Token expiry is sufficiently high in Portal so I'm a bit perplexed as to why it will fail intermittently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants