ArcGIS Online generateToken does not work?

12734
6
Jump to solution
05-11-2016 06:36 AM
nita14
by
Occasional Contributor III


Hi All,

I try to user token-based authentication to ArcGIS Online using my developers.arcgis.com account.

I pass the following request "https://www.arcgis.com/sharing/generateToken?username=myname&password=mypass&client=requestip&f=json "

However, my request seems to be invalid, as I receive the message "{"error":{"code":400,"message":"Unable to generate token.","details":["Invalid username or password."]}}". The credentials are 100% good.

My question is: can I still use token-based authentciation for ArcGIS Online and Portal for ArcGIS or should go with OAuth?

Thanks,

Adam

1 Solution

Accepted Solutions
KellyGerrow
Esri Frequent Contributor

Hi Adam,

Token based authentication is still supported. The error message indicates that your username and/or password was incorrect. When submitting a username directly to the REST API, as you are, the username is case sensitive. The username is not case-sensitive when submitting through the login prompt to ArcGIS Online. Try checking the case of your username and resubmitting the request.

Also, are you submitting this as a post request? This is a requirement for this call.

-Kelly

View solution in original post

6 Replies
KellyGerrow
Esri Frequent Contributor

Hi Adam,

Token based authentication is still supported. The error message indicates that your username and/or password was incorrect. When submitting a username directly to the REST API, as you are, the username is case sensitive. The username is not case-sensitive when submitting through the login prompt to ArcGIS Online. Try checking the case of your username and resubmitting the request.

Also, are you submitting this as a post request? This is a requirement for this call.

-Kelly

nita14
by
Occasional Contributor III

Hi Kelly,

Indeed, I did not check the case sensitivity of the username. Now, it works just fine. What I find awkward, is the different way of handling username by ArcGIS Online, which is why I stated my username was just fine as I could login to ArcGIS Online. Anyway, thank you very much for help!

Adam

DeveshDevesh-iSpace
New Contributor

That really helps. Information about case sensitive.

by Anonymous User
Not applicable

Kelly,

Thank you!! I have been mulling over this issue for a while now trying to figure out why I could get a token from one ArcGIS Online account but not another running from the same script on the same machine etc. Turns out it was case sensitivity in the username as well. I find it odd that this isn't documented anywhere. I, along with probably a lot of other folks, assumed that wouldn't be an issue. I have been searching high and low and this is the only mention of case sensitivity regarding the username. Maybe I just missed that small but very important detail!? Anyhow, thank you again  

0 Kudos
KellyGerrow
Esri Frequent Contributor

Jared Schuckert‌,

This is a bit of a tricky concept. Changes were made to the ArcGIS Online sign in to work around the case sensitivity but you need to write in this code in custom scripts or be aware of the case of your username when making direct calls to the REST API.

Another option is to use the client_ID and client secret as outlined in this dev lab to get around the issue with case sensitivity all together:

Get an access token | ArcGIS for Developers 

I'll see where we can improve information about this  detail.

-Kelly

0 Kudos
Dunn_Jeremy
New Contributor III

Morning All

I'm having the same issue. I'm trying to update some feature layers on AGOL with a python script (notebook script really). 

I know my user credentials are correct as I can login to my AGOL account. The error I get is as below 

RuntimeError: Unable to generate token.
Invalid username or password.
(Error Code: 400)

I understand the username and password is case sensitive, and I'm pretty sure they are correct...I'm using the credentials as below 

print("Login to AGOL")
from arcgis.gis import GIS
#gis = GIS("home")
username = ""
password = ""
org_url = r"https://company.maps.arcgis.com/"
gis = GIS(org_url, username, password)
print("Successfully logged in as: " + gis.properties.user.username)

Any suggestions as to how I can fix this  ? 

Regards. 

Jeremy

0 Kudos