google.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:gcp-tools 作者: lukwam 项目源码 文件源码
def auth(
            self,
            client_secrets_file=None,
            service_account_file=None,
            sub_account=None,
    ):
        """Athenticate with gcloud application-default credentials."""
        if client_secrets_file:
            credentials = self.auth_stored_credentials(
                client_secrets_file=client_secrets_file,
                scopes=self.scopes
            )

        elif service_account_file:
            credentials = ServiceAccountCredentials.from_json_keyfile_name(
                service_account_file,
                scopes=self.scopes,
            )
            if sub_account:
                credentials = credentials.create_delegated(sub_account)

        else:
            # get application-default credentials from gcloud
            credentials = GoogleCredentials.get_application_default()

        self.credentials = credentials
        self.http = credentials.authorize(httplib2.Http())


        #
        # build the various services that we'll need
        #

        # admin directory
        self.admin = build('admin', 'directory_v1', credentials=credentials)

        # build a cloud billing API service
        self.billing = build('cloudbilling', 'v1', credentials=credentials)

        # build a compute API service
        self.compute = build('compute', 'v1', credentials=credentials)
        self.compute_alpha = build('compute', 'alpha', credentials=credentials)

        # build a cloud resource manager API service
        self.crm = build('cloudresourcemanager', 'v1', credentials=credentials)

        # build an iam API service
        self.iam = build('iam', 'v1', credentials=credentials)

        # build a service management API service
        self.smgt = build('servicemanagement', 'v1', credentials=credentials)

        # build a service management API service
        self.storage = build('storage', 'v1', credentials=credentials)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号