简体   繁体   English

Flask-OAuthlib从令牌处理程序获取access_token

[英]Flask-OAuthlib get access_token from token handler

I need to return custom user fields on successful access_token request from @oauth.token_handler. 我需要从@ oauth.token_handler成功的access_token请求返回自定义用户字段。 I see this can be done if I return some json data like this example from the docs 如果我从文档中返回一些像这个例子的json数据,我看到这可以完成

@app.route('/oauth/token')
@oauth.token_handler
def access_token():
    return {'version': '0.1.0'}

But how can I access the user information from the original request or the obtained access_token in here? 但是如何在此处访问原始请求或获取的access_token中的用户信息?

Thanks 谢谢

I think you can't do that because @oauth.token_handler is outside the scope of the current request. 我认为你不能这样做,因为@oauth.token_handler不在当前请求的范围内。

I solved by providing a /me endpoint which provides the current logged user's info: request.oauth.user . 我解决了提供/me端点,它提供了当前登录用户的信息: request.oauth.user

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM