Comments (23)
btw. I'm using Python 2.7.1
from gspread.
It looks like the primary issue might be that your authentication schema is incorrect. in client.py, line 31-32 look like this:
AUTH_SERVER = 'https://www.google.com'
SPREADSHEETS_SERVER = 'spreadsheets.google.com'
While signing into a Google property takes me to this URL:
https://accounts.google.com/ServiceLogin
from gspread.
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?
from gspread.
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.
from gspread.
from gspread.
Great, many thanks for discovering this!
from gspread.
No problem. Your library works great.
from gspread.
Thank you
from gspread.
gdata does seem to work for me is I instead use an application-specific password from the two-factor authentication settings page...
from gspread.
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~
from gspread.
Thanks for sharing this!
from gspread.
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.
from gspread.
@tcorbettclark Thanks for the finding!
from gspread.
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:
- Mark the activity as not suspicious: https://security.google.com/settings/security/activity?hl=en&pli=1
- Bypass the capcha: http://www.google.com/accounts/DisplayUnlockCaptcha (thanks to http://serverfault.com/questions/550189/gmail-rejecting-imap-calls-from-aws-ec2-hosted-james-server#comment636128_550189 )
I hope this helps.
from gspread.
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!
from gspread.
@jwal .. thanks , you comment saved my time.
from gspread.
@jwal saves lifes.
from gspread.
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!
from gspread.
thx @sanderjo
from gspread.
@sanderjo Thanks for the feedback 👍
from gspread.
@jwal Thanks for the helpful comment! The second step worked for me.
from gspread.
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:
gspread.exceptions.AuthenticationError: Unable to authenticate. 403 code with content
Error=BadAuthentication
Url=https://www.google.com/accounts/ContinueSignIn?blabla
Info=WebLoginRequired
Googling "Info=WebLoginRequired" led me to that URL https://accounts.google.com/DisplayUnlockCaptcha
HTH
from gspread.
Please update your GSpread API Reference.
The GSpread API Reference still says:
gspread.login(email, password)
Login to Google API using email and password.
This is a shortcut function which instantiates Client and performs login right away.
Returns: Client instance.
But, when I run it that way it says:
Warning:
ClientLogin is deprecated:
https://developers.google.com/identity/protocols/AuthForInstalledApps?csw=1
Authorization with email and password will stop working on April 20, 2015.
from gspread.
Related Issues (20)
- Update conda forge package HOT 2
- A way to add DataValidation HOT 6
- Missing py.typed marker HOT 1
- AttributeError: 'HTTPClient' object has no attribute 'import_csv' HOT 3
- Unable to read public readonly spreadsheet HOT 4
- Add missing types HOT 2
- Disambiguating and filling in headers similar to Pandas HOT 8
- worksheet.add_protected_range() - impossible to create the `warning_only=True` range HOT 2
- ADC Authentication HOT 2
- HTTPSConnectionPool(host='oauth2.googleapis.com', port=443): Max retries exceeded with url: /token (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1000)'))) HOT 2
- Questions about Copilot + Open Source Software Hierarchy HOT 1
- gspread depends on google-auth>2.4.0 but only specifies google-auth>=1.12.0 HOT 7
- Client.copy(..., copy_permissions=True) breaks when permission type is domain HOT 1
- Remove StrEnum dependency HOT 6
- Add support for append columns HOT 5
- Feature request. Batch Merge in worksheet class HOT 4
- lint failure HOT 1
- get_notes from a range HOT 3
- check Spinx will work with RTD
- Exception requests.exceptions.JSONDecodeError is raised in APIError constructor HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gspread.