コード例 #1
0
def load_stored_token():
    path = config.get_storage_path(config.get('Dropbox', 'storage'))
    if not os.path.isfile(path):
        return
    with open(path, 'r') as f:
        token = json.loads(f.read())
    return token
コード例 #2
0
def setup():
    global http
    storage = Storage(config.get_storage_path(config.get('OAuth', 'storage')))
    credentials = storage.get()
    if credentials is None or credentials.invalid is True:
        flow = OAuth2WebServerFlow(
            client_id=config.get('OAuth', 'client_id'),
            client_secret=config.get('OAuth', 'client_secret'),
            scope=config.get('OAuth', 'scope'),
            user_agent=config.get('OAuth', 'user_agent'))
        credentials = run(flow, storage)
    if config.DEBUG and credentials.access_token_expired:
        print 'Credentials expired'
    http = credentials.authorize(http)
コード例 #3
0
def store_token(token):
    data = {'key': token.key, 'secret': token.secret}
    path = config.get_storage_path(config.get('Dropbox', 'storage'))

    with open(path, 'w') as f:
        f.write(json.dumps(data))