コード例 #1
0
ファイル: facebook.py プロジェクト: impressiver/gooderlooking
def facebook_authorized(resp):
    expires = datetime.utcnow() + timedelta(seconds=long(resp['expires']))
    oauth_authorized(provider='facebook', token=resp['access_token'], expires=expires)
    
    # Update service with user id and name
    me = facebook.get('/me')
    current_user.service('facebook').service_user_id = me.data['id']
    current_user.service('facebook').screen_name = me.data['name']
    db.session.commit()
    
    import_albums(current_user.service('facebook'))
    
    return redirect(url_for('account.profile'))
コード例 #2
0
ファイル: views.py プロジェクト: impressiver/gooderlooking
def unlink(target):
    current_app.logger.debug("unlink: %s", target)
    
    service = current_user.service(target)
    if service:
        current_user.services.remove(service)
        db.session.commit()
    
    
    return redirect(url_for('account.profile'))
コード例 #3
0
ファイル: google.py プロジェクト: impressiver/gooderlooking
def google_authorized(resp):
    current_app.logger.debug(resp)
    
    oauth_authorized(provider='google', token=resp['access_token'])
    
    # Update service with user id and name
    info = google.get(endpoints['profile'], headers={'Authorization': 'OAuth ' + resp['access_token']})
    current_app.logger.debug(json.dumps(info.data))
    
    current_user.service('google').service_user_id = info.data['id']
    current_user.service('google').screen_name = info.data['email']
    current_user.service('google').first_name = info.data['given_name']
    current_user.service('google').last_name = info.data['family_name']
    
    if info.data['email'] and not current_user.email:
        current_user.email = info.data['email']
        
    db.session.commit()
    
    import_photos(current_user.service('google'))
    
    return redirect(url_for('account.profile'))
コード例 #4
0
def foursquare_authorized(resp):
    current_app.logger.debug(resp)
    
    oauth_authorized(provider='foursquare', token=resp['access_token'])
    
    # Update service with user id and name
    current_app.logger.debug(_get_endpoint('users/self'))
    info = foursquare.get(_get_endpoint('users/self'))
    current_app.logger.debug(json.dumps(info.data))
    
    current_user.service('foursquare').service_user_id = info.data['response']['user']['id']
    current_user.service('foursquare').first_name = info.data['response']['user']['firstName']
    current_user.service('foursquare').last_name = info.data['response']['user']['lastName']
    
    if info.data['response']['user']['firstName'] and not current_user.first_name:
        current_user.first_name = info.data['response']['user']['firstName']
        current_user.last_name = info.data['response']['user']['lastName']
        
    if info.data['response']['user']['homeCity'] and not current_user.city:
        current_user.city = info.data['response']['user']['homeCity']
        
    db.session.commit()
    
    return redirect(url_for('account.profile'))
コード例 #5
0
def foursquare_token():
    if current_user.is_authenticated():
        service = current_user.service('foursquare')
        if service:
            return service.token, ''
コード例 #6
0
ファイル: facebook.py プロジェクト: impressiver/gooderlooking
def facebook_token():
    if current_user.is_authenticated():
        service = current_user.service('facebook')
        if service:
            return service.token, ''
コード例 #7
0
ファイル: twitter.py プロジェクト: impressiver/gooderlooking
def twitter_token():
    if current_user.is_authenticated():
        service = current_user.service('twitter')
        if service:
            return service.token, service.secret
コード例 #8
0
ファイル: google.py プロジェクト: impressiver/gooderlooking
def google_token():
    if current_user.is_authenticated():
        service = current_user.service('google')
        if service:
            return service.token, ''