Skip to content
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

2-Factor OAuth Login #13

Open
brandon15811 opened this issue Jul 12, 2016 · 5 comments
Open

2-Factor OAuth Login #13

brandon15811 opened this issue Jul 12, 2016 · 5 comments

Comments

@brandon15811
Copy link

Since I didn't see this implemented here: If you login with gpsoauth.perform_master_login using your regular username and password on an account with 2 factor auth enabled, it'll return a url, and after you open that url and finish logging in, it'll then redirect you to https://accounts.google.com/o/oauth2/programmatic_auth, and there's a cookie set named oauth_token, which includes the OAuth token.

The caveat here is that you can't use javascript (like a bookmarklet) to extract it, since the cookie is set HttpOnly, so you'll either have to manually extract it, use an extension, or something like Selenium.

You can also get that cookie by starting with the URL (in a browser) https://accounts.google.com/o/android/auth?&source=android&lang=en&langCountry=en_us&xoauth_display_name=Android%20Phone&cc=us&tmpl=new_account and logging in instead of https://android.clients.google.com/auth

@simon-weber
Copy link
Owner

Ah, yeah, I looked into this when first implementing the flow but never got around to supporting it: simon-weber/gmusicapi#168 (comment).

That's a bummer that the cookie is httponly. Sounds like that really pushes things towards option 2 in the linked comment.

@brandon15811
Copy link
Author

When I was working on automating this with selenium a few months ago, for some reason I used the selector [id$=in], which finds all the forms with an ID that ends in "in" (like totpPin). Unfortunately, I don't remember why I did that.

But also, the url that's returned in the gpsoauth.perform_master_login response is also used for other purposes sometimes (like when a google apps account has SSO on, or when google wants a security check)

@simon-weber
Copy link
Owner

Cool; good to know.

@HoffmannP
Copy link

HoffmannP commented Jul 17, 2016

Go to appPasswords and create one. Use this as your password.

@B16f00t
Copy link

B16f00t commented Sep 25, 2019

With selenium it's easy to get the Oauth2 token, but when I try to use it to get the google drive token, it doesn't work. Any method to get the google drive token from Oauth2?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants