Esempio n. 1
0
    def __init__(self, app_creds=None, sub=None):
        setup_google_application_credentials(app_creds)

        self.client = ServiceAccountCredentials.from_json_keyfile_name(
            os.environ['GOOGLE_APPLICATION_CREDENTIALS'],
            ['https://www.googleapis.com/auth/admin.directory.group']
        ).create_delegated(sub).authorize(httplib2.Http())
Esempio n. 2
0
    def __init__(self, app_creds=None, project=None, location=None):
        setup_google_application_credentials(app_creds)

        self.project = project
        self.location = location

        # We will not create the client until we need to use it, since creating the client
        # without valid GOOGLE_APPLICATION_CREDENTIALS raises an exception.
        # This attribute will be used to hold the client once we have created it.
        self._client = None
    def __init__(self, app_creds=None, project=None):

        setup_google_application_credentials(app_creds)

        # Throws an error if you pass project=None, so adding if/else statement.
        if not project:
            self.client = storage.Client()
            """
            Access all methods of `google.cloud` package
            """
        else:
            self.client = storage.Client(project=project)
Esempio n. 4
0
    def __init__(self, google_keyfile_dict=None):

        scope = [
            'https://spreadsheets.google.com/feeds',
            'https://www.googleapis.com/auth/drive',
        ]

        setup_google_application_credentials(google_keyfile_dict,
                                             'GOOGLE_DRIVE_CREDENTIALS')
        google_credential_file = open(os.environ['GOOGLE_DRIVE_CREDENTIALS'])
        credentials_dict = json.load(google_credential_file)

        credentials = ServiceAccountCredentials.from_json_keyfile_dict(
            credentials_dict, scope)
        self.gspread_client = gspread.authorize(credentials)