auth.py 文件源码

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

项目:gmailtool 作者: adamandpaul 项目源码 文件源码
def cmd_auth(args):
    """The authentication command
    """
    logger.debug('Running command auth')

    credentials_storage_path = os.path.join(args.profile_dir, config.oauth_credentials_storage_filename)
    credentials_storage = oauth2client.file.Storage(credentials_storage_path)
    credentials = credentials_storage.get()
    if credentials is None or credentials.invalid:

        client_secret_file_handle, client_secret_path = tempfile.mkstemp()
        client_secret_fout = os.fdopen(client_secret_file_handle, 'w')
        json.dump(config.oauth_client_secret, client_secret_fout)
        client_secret_fout.close()
        flow = oauth2client.client.flow_from_clientsecrets(client_secret_path,
                                                           config.oauth_scopes)
        flow.user_agent = config.oauth_application_name
        credentials = oauth2client.tools.run_flow(flow, credentials_storage, args)
        os.remove(client_secret_path)

    return credentials
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号