installed_app.py 文件源码

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

项目:appbackendapi 作者: codesdk 项目源码 文件源码
def main(args):
    storage = Storage('credentials.dat')
    credentials = storage.get()

    if credentials is None or credentials.invalid:
        flow = flow_from_clientsecrets(
            CLIENT_SECRETS, scope=SCOPES)
        # run_flow will prompt the user to authorize the application's
        # access to BigQuery and return the credentials.
        credentials = tools.run_flow(flow, storage, args)

    # Create a BigQuery client using the credentials.
    bigquery_service = discovery.build(
        'bigquery', 'v2', credentials=credentials)

    # List all datasets in BigQuery
    try:
        datasets = bigquery_service.datasets()
        listReply = datasets.list(projectId=args.project_id).execute()
        print('Dataset list:')
        pprint.pprint(listReply)

    except HttpError as err:
        print('Error in listDatasets:')
        pprint.pprint(err.content)

    except AccessTokenRefreshError:
        print('Credentials have been revoked or expired, please re-run'
              'the application to re-authorize')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号