I mpaper Sina Weibouser through oauth2 to increase accreditation to currentuser who have beenloged in with my own website s account, since OAuth2 use a redirect-questback mechanism, it trends that after this practice, and in the Callback viewhandler, the flask. 会议完全是一个新目标。 因此,一失去目前用户的标识。
...... 在同一个浏览器(如Landor)中,添加一个新的表格并访问我的网页(www.funfunsay.com),本届会议的物体仍然存在!
因此,有两部地图。 同一浏览器场的会议?
我写了一个非常简单的模块,除我失去旧会议外,它很好地与Sina Weibo有关。
# -*- coding: utf-8 -*-
from flask import (Flask, render_template, current_app, request,
flash, url_for, redirect, session, g, abort)
# For import *
__all__ = [ create_app ]
app = Flask(__name__)
app.config[ DEBUG ] = True
app.secret_key = secret key
@app.before_request
def before_request():
print "before request:", session
#<1st output>for first visit www.funfunsay.com, the output is: before request: <SecureCookieSession {}>
#<3rd output>for callback from sina, the output is the same
@app.after_request
def after(response):
print "after request:", session
#<2nd output>for first visit www.funfunsay.com, the output is: after request: <SecureCookieSession { testinfo : abc }*>
return response
@app.route( / )
def hello_world():
print "request:", request
login_uri = https://api.weibo.com/oauth2/authorize?redirect_uri=http%3A//funfunsay.com/connect/sina/callback&response_type=code&client_id=3921006605&display=default
session[ testinfo ] = abc #a key-value for test
return redirect(login_uri)
@app.route("/connect/sina/callback")
def connect_sina_callback():
print "connect_sina_callback: ", session
#<4th output>will output: connect_sina_callback: <SecureCookieSession {}>
return Callback success!
if __name__ == __main__ :
app.run( 0.0.0.0 , 80)
PS:为了测试目的,我在东道方档案中添加“127.0.0.1 www.funfunsay.com”。