Ejemplo n.º 1
0
def finish_oauth():
  uid = flask.request.args.get('uid', type=int)
  token = flask.request.args.get('oauth_token')
  stored_token = flask.session.get(token)
  if stored_token and uid:
    request_token = oauth.oauth.OAuthToken.from_string(stored_token)
    access_token = session.obtain_access_token(request_token)
    token_str = "%s|%s" % (access_token.key, access_token.secret)
    DropboxUser.add_user(uid, token_str)
    flask.session['uid'] = uid
  else:
    app.logger.debug('No stored access token found!')

  return flask.redirect(flask.url_for('stats'))
Ejemplo n.º 2
0
def quota_info():
    uid = flask.session.get("uid", -1)
    dropbox_uid = flask.request.args.get("uid", uid, type=int)
    account_info = DropboxUser.get_account_info(dropbox_uid) or {}
    quota_info = account_info.get("quota_info")
    data = []
    if quota_info:
        quota_info["free"] = quota_info["quota"] - (quota_info["normal"] + quota_info["shared"])
        del quota_info["quota"]
        data = map(list, quota_info.items())
    return flask.jsonify(result=data)