ArcGIS Online generateToken does not work?

6274
5
Jump to solution
05-11-2016 06:36 AM
nita14
by
Regular Contributor


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

Reply
0 Kudos
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

5 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

View solution in original post

nita14
by
Regular Contributor

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

Reply
0 Kudos
JaredSchuckert
Occasional Contributor

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  

Reply
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

Reply
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

Reply
0 Kudos