-
Notifications
You must be signed in to change notification settings - Fork 953
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
Unable to authenticate. 403 code #45
Comments
btw. I'm using |
It looks like the primary issue might be that your authentication schema is incorrect. in client.py, line 31-32 look like this:
While signing into a Google property takes me to this URL:
|
Or maybe not. I tried the official Google Python library and it gives me the same error. I don't get it. I've logged in successfully, then copied/pasted my credentials into the login method and still no joy. Is my pw supposed to be plain text in the login method call? |
Looks like this was an issue with Google's two factor authorization. I'm submitting a pull request to update the docs for other's benefit. |
Great, many thanks for discovering this! |
No problem. Your library works great. |
Thank you |
gdata does seem to work for me is I instead use an application-specific password from the two-factor authentication settings page... |
It's happens to me too, but in my case, it was caused by login to google from a suspicious ip. so I login the online account and find google warn me with the message "We detected activity on your Google Account from a location you don't usually sign in from. Review the information below and tell us whether you recognize this activity". I can recognize that activity and it works. Thanks for the great library~ |
Thanks for sharing this! |
gspread works fine for me with two factor authentication. You just need to create and use an application-specific password: https://accounts.google.com/b/0/IssuedAuthSubTokens?hl=en_GB Your username is your email as usual. It is better this way anyway since your main user password is not used anywhere near your code, and the application specific password can be discarded/revoked independently. |
@tcorbettclark Thanks for the finding! |
You can also get a 403 error when Google thinks that your login is suspicious. I was logging in using a dedicated robot Google account from a Jenkins server hosted on Amazon EC2. I had to do two things:
I hope this helps. |
I came here looking for exactly the answer @tcorbettclark gave. It was my 2-factor auth. I had also been wondering how the heck I could get away from using my personal password in my script anyway. Thanks! |
@jwal .. thanks , you comment saved my time. |
@jwal saves lifes. |
To confirm & FYI: I had the same "gspread.exceptions.AuthenticationError: Unable to authenticate. 403 code" After the failed gspread logon, I immediately received a mail from Google/Gmail ([email protected]) in my gmail about a suspicous login attempt. I confirmed the login request was OK, and went to https://www.google.com/settings/security/lesssecureapps to accept lower-security apps to access my gmail account. After that, the gspread login went OK. PS: @burnash What a fantastic piece of software gspread is. Thank you very much! |
thx @sanderjo |
@sanderjo Thanks for the feedback 👍 |
@jwal Thanks for the helpful comment! The second step worked for me. |
And one more update: I got the 403 with another account I just created, and clicking on the URL https://www.google.com/settings/security/lesssecureapps did not solve it. More digging revealed I had to also go to this URL: https://accounts.google.com/DisplayUnlockCaptcha, and after that I could use gspread. FWIW: I put some extra logging into line 112 of gspread/client.py and that revealed this:
Googling "Info=WebLoginRequired" led me to that URL https://accounts.google.com/DisplayUnlockCaptcha HTH |
Please update your GSpread API Reference. The GSpread API Reference still says: gspread.login(email, password) But, when I run it that way it says: |
Trying to login to test this library out and I'm getting an error. I've made sure to install gspread. I created a single python file,
test.py
. My code is as simple as it gets:Yet when I run this via the terminal
python test.py
I get the following error:I confirmed that my login credentials were correct by logging out of Google docs, then logging back in, then copying and pasting the u/p into
test.py
and still nothing. Any suggestions?The text was updated successfully, but these errors were encountered: