Exemplo n.º 1
0
def auth_sina(r):
    #callback    
    auth = OAuthHandler("2453342288", "2c545e783036afe3ae1cfef1e24ba9fb", "%s/callback" % APP_ROOT)
    auth_url = auth.get_authorization_url()
    r.session['request_token'] = auth.request_token
    logging.info("url:%s" % auth_url)
    logging.info("request_token:%s" % str(auth.request_token))
    
    return HttpResponseRedirect(auth_url)
Exemplo n.º 2
0
def callback(r):
    auth = OAuthHandler("2453342288", "2c545e783036afe3ae1cfef1e24ba9fb", )

    verifier = r.GET['oauth_verifier']
    rtoken = r.session['request_token']
    auth.set_request_token(rtoken.key, rtoken.secret)
    access_token = auth.get_access_token(verifier)
    
    api = API(auth)
    user = api.verify_credentials()    
    logging.info("user:%s" % str(user))
    
    p = WeiboProfile.import_from_sina(user, auth)
    r.session['login_user'] = p.user
    r.session['login_weibo'] = p
    
    return HttpResponseRedirect("%s/my" % APP_ROOT)