gmail-import.py 文件源码

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

项目:rube-gmail 作者: bonzini 项目源码 文件源码
def get_credentials(client_secret_file, credentials_file, scopes, user_agent, args=None):
    """Gets valid user credentials from storage.

    If nothing has been stored, or if the stored credentials are invalid,
    the OAuth2 flow is completed to obtain the new credentials.

    Returns:
        Credentials, the obtained credential.
    """
    store = oauth2client.file.Storage(credentials_file)
    credentials = store.get()
    if not credentials or credentials.invalid:
        flow = oauth2client.client.flow_from_clientsecrets(client_secret_file, scopes)
        flow.user_agent = user_agent
        if args:
            credentials = oauth2client.tools.run_flow(flow, store, args)
        else: # Needed only for compatibility with Python 2.6
            credentials = oauth2client.tools.run(flow, store)
        print('Storing credentials to ' + credentials_file)
    return credentials



# If modifying these scopes, delete your previously saved credentials
# at ~/.credentials/gmail-python-import.json
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号