Login to arcgis.gis as arcgis online user fails when "@" symbol followed by number in password

896
4
Jump to solution
08-14-2023 08:56 AM
ClaytonBurns2
New Contributor III

I'm pretty new to python and when logging into a users arcgis online account in python 3.9.13 with arcgis.gis as

gis=GIS(url='ago url', username=u, password=p)

and there is an "at" symbol followed by numbers in the password the connection fails with an "Exception: Unable to generate token. Invalid username or password" error. When the exact same username and password is used in AGO Notebook it works fine.

I've tried multiple things to make it work including urllib.parse.qoute, p.format, and some others, but can't get anything to work so far. Is there a solution out there I could try or is this an issue with the API? "At" symbols work fine with other user passwords, just not when there is a number following it. Has anyone else run into this issue and resolved it?

ClaytonBurns2_0-1692021388531.pngClaytonBurns2_1-1692021416984.png

Works just fine in AGO Notebook:

ClaytonBurns2_2-1692021499678.png

 

0 Kudos
1 Solution

Accepted Solutions
ClaytonBurns2
New Contributor III

Hi David, 

Thank you for the responses and followup. I just realized this morning that the issue had nothing to do with the passwords, but instead was that the username was not input into my python editor with the actual capitalized letters that the account was setup with. The client I was working with provided the username as all lower case, which worked for logging into ArcGIS Online and when input into ArcGIS Online notebook for the login credentials. However, when inputting the username into python running in Visual Studio it was case sensitive.

Just so happened the two accounts with this incorrect username issue were the only accounts with an @ symbol followed by a number in the password and so I went with the wrong rabbit trail in troubleshooting. Thanks again for your responses and I'll close this question now.

View solution in original post

4 Replies
David_McRitchie
Esri Contributor

Hey Clay,

 

I am not aware of @ being a limitation when used as a login string but as an alternative, you could try logging in with this account to ArcGIS Pro then use the following code in your notebook for the login.

 

from arcgis import GIS
GIS = ("home")

 

Hope that helps!

David

Esri UK -Technical Support Analyst
0 Kudos
ClaytonBurns2
New Contributor III

Thanks for the response David! The password will work in ArcGIS Online Notebook just fine. The issue is when I move the code to run out of python directly it then fails. I'm trying to assist a client so that their data report can be emailed to them weekly instead of them having to login to ArcGIS Online Notebook each week and download the excel file.

Other clients connections that have the @ symbol in their passwords work fine except for the few I've tested that have @ with a number following it. Then the login fails. Simplest solution will be that I just ask the client to update their password, but I'm hoping to find a solution instead if possible as it doesn't seem like this should be a problem.

0 Kudos
David_McRitchie
Esri Contributor

Hey Clay,

In that case I am uncertain and it depends how the code is being ran. Is a .py script being used by Command Line or is it be sceduled to run from an IDE?

Many thanks,

David

 

Esri UK -Technical Support Analyst
0 Kudos
ClaytonBurns2
New Contributor III

Hi David, 

Thank you for the responses and followup. I just realized this morning that the issue had nothing to do with the passwords, but instead was that the username was not input into my python editor with the actual capitalized letters that the account was setup with. The client I was working with provided the username as all lower case, which worked for logging into ArcGIS Online and when input into ArcGIS Online notebook for the login credentials. However, when inputting the username into python running in Visual Studio it was case sensitive.

Just so happened the two accounts with this incorrect username issue were the only accounts with an @ symbol followed by a number in the password and so I went with the wrong rabbit trail in troubleshooting. Thanks again for your responses and I'll close this question now.