Coder Social home page Coder Social logo

scottphilip / google-token Goto Github PK

View Code? Open in Web Editor NEW
3.0 0.0 1.0 64 KB

Google User Account Token Generator

License: GNU General Public License v3.0

Python 100.00%
google oauth2 authentication automation cookie authentication-token refresh-tokens oauth

google-token's Introduction

https://travis-ci.org/scottphilip/google-token.svg?branch=master

Google Token

Python Package allowing Google Account Authorization Tokens to be issued when user is not in attendance.

Installation Instructions

pip install GoogleToken

Properties

When manually logging into a Google Account secured web application, the initial URL will be in the format;

https://accounts.google.com/o/oauth2/v2/auth?response_type=token&client_id=0000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com&redirect_uri=https://www.website.com/google/callback&scope=https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/userinfo.profile
Property Example
Client Id 0000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleuser content.com
Redirect Uri https://www.website.com/google/callback
Scope https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile

Usage Instructions

First time login will create a Cookies file which stores the issued tokens which will subsequently be reused. It is recommended not to the password or the OTP secret in configuration. Once the cookies file is created the credentials are not required.

from GoogleToken import GoogleTokenGenerator, GoogleTokenParameters
parameters = GoogleTokenParameters(oauth_client_id="0000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
                          oauth_redirect_uri="https://www.website.com/google/callback",
                          oauth_scope="https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile",
                          account_email="[email protected]",
                          account_password="password",
                          account_otp_secret="secret")
generator = GoogleTokenGenerator(parameters)
token = generator.generate()
print(token)

Once the cookies file is created, the credentials can be omitted.

from GoogleToken import get_google_token
token, expiry = get_google_token(account_email="[email protected]",
                                 account_password="password",
                                 account_otp_secret="secret",
                                 oauth_client_id="0000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
                                 oauth_redirect_uri="https://www.website.com/google/callback",
                                 oauth_scope="https://www.googleapis.com/auth/userinfo.profile")

Dependencies

Selenium

Pyotp

Credits

Scott Philip

Berlin, Germany

Licence

GNU General Public License (Version 3, 29 June 2007)

CallerLookup Copyright © 2017 Scott Philip

google-token's People

Contributors

scottphilip avatar

Stargazers

 avatar  avatar  avatar

Forkers

5l1v3r1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.