当我向 facebook 执行get_authorize_url
请求时,我被重定向到以下内容URL
(在浏览器中看到):
http://127.0.0.1:5000/#access_token=sdfsdfasfaf&expires_in=5849
但我无法获得这个 access_token in flask
:它不在request.args
,它不在request.query_string
,它甚至不在那里request.url
。也许烧瓶的#
角色有问题?如何访问该查询参数?
这是我的代码的相关部分(源自rauth
facebook-cli 示例):
# rauth OAuth 2.0 service wrapper
graph_url = 'https://graph.facebook.com/'
facebook = OAuth2Service(name='facebook',
authorize_url='https://www.facebook.com/dialog/oauth',
access_token_url=graph_url + 'oauth/access_token',
client_id=app.config['FB_CLIENT_ID'],
client_secret=app.config['FB_CLIENT_SECRET'],
base_url=graph_url)
...
@app.route('/facebook/login')
def login():
redirect_uri = url_for('authorized', _external=True)
params = {'scope': 'read_stream',
'response_type': 'token',
'redirect_uri': redirect_uri}
return redirect(facebook.get_authorize_url(**params))
@app.route('/facebook/authorized')
def authorized():
# I am not able to find the access_token
print dir(request)
print request.args
print request.query_string
print request.url
...