示例#1
0
文件: api.py 项目: joehand/handAPI
    def change_header(uri, headers, body):
        oauth_token = current_user.get('services')['fitbit']['oauth_token_secret']

        auth = headers.get('Authorization')
        if auth:
            print auth
            auth = auth + ', oauth_token="%s"' %oauth_token
            headers['Authorization'] = auth
        
        print uri
        print headers
        print body

        return uri, headers, body
示例#2
0
 def get_token(self, token=None):
     if self.blueprint.api.oauth_type == 'oauth2':
         return current_user.get('services')[self.blueprint.name]['access_token']
     return current_user.get('services')[self.blueprint.name]['oauth_token']
示例#3
0
 def dispatch_request(self):
     if self.blueprint.name in current_user.get('services'):
         print('going here')
         flash('Already signed in to %s' % self.blueprint.name.capitalize())
         return redirect(url_for('frontend.index'))
     return self.blueprint.oauth.authorize(callback=url_for('.authorized', _external=True))
示例#4
0
文件: views.py 项目: joehand/handAPI
def user():
    if bp.name in current_user.get('services'):
        data = {'user_id': current_user.get('services')[bp.name]['user_id']}
        resp = bp.oauth.get('users/show.json', data=data)
        return jsonify(resp.data)
    return redirect(url_for('.login'))
示例#5
0
文件: views.py 项目: joehand/handAPI
def user():
    if bp.name in current_user.get('services'):
        resp = bp.oauth.get('me')
        return jsonify(resp.data)
    return redirect(url_for('.login'))
示例#6
0
文件: views.py 项目: joehand/handAPI
def user():
    if bp.name in current_user.get("services"):
        resp = bp.oauth.get("user")
        return jsonify(resp.data)
    return redirect(url_for(".login"))