如何用flask_oauthlib交换访问令牌的一次性授权码?

How to exchange one-time authorization code for access token with flask_oauthlib?

我正在用 Python Flask framework in which I now receive a "one-time authorization code" from an app which I supposedly can exchange for an access and refresh token with the Gmail API (described here).

构建一个 API

我一直在使用 Oauthlib for regular authorizations in the browser, which works perfectly fine. So I found this page with some example code of how to implement this. The code in the example starts off with from your_validator import your_validator and I'm immediately stuck. I found something here about implementing a custom validator, but at the top of that page it says that flask_oauthlib 已经实现了这个。

有没有人举例说明如何使用 flask_oauthlib 交换一次性授权码以获取访问权限和刷新令牌?欢迎所有提示!

我没有使用 Oauthlib 的示例,但这里有一个使用 oauth2client 库的示例。 https://github.com/googleplus/gplus-quickstart-python

查看 flask_oauthlib,handle_oauth2_response 似乎是您需要使用 codeaccess_token 交换的方法。