Exemple #1
0
def handler():
    if Constants.param_oauth_verifier in request.query:
        access_token_url = Util.getTwitterAccessTokenUrl(request.query.get(Constants.param_oauth_token),
            request.query.get(Constants.param_oauth_verifier))
        resp, data = Util.getTwitterClient().request(access_token_url, 'POST')
        if resp['status'] == "200":
            access_token = dict(urlparse.parse_qsl(data))
            Util.upserttw(access_token)
    redirect('/')
Exemple #2
0
def handler():
    if not Util.connected_to_twitter():
        twitter_client = Util.getTwitterClient()
        request_token_url = Util.getTwitterRequestTokenUrl()
        resp, data = twitter_client.request(request_token_url, 'GET')
        if resp['status'] == '200':
            request_token = dict(urlparse.parse_qsl(data))
            Util.setTwitterRequestToken(request_token[Constants.param_oauth_token],
                request_token[Constants.param_oauth_secret])
            auth_url = Util.getTwitterAuthUrl(request_token[Constants.param_oauth_token])
            redirect(auth_url)
    redirect('/')