Tutorial for using requests_oauth2

坚强是说给别人听的谎言 提交于 2019-11-30 03:51:59

The best source of information that I could find is the documentation (and of course the source code) of the requests-oauth2 project on Github:

The document also contains an "Interesting readings" section with some links to additional tutorials. For a general overview of the OAuth2 process flow, have a look at this tutorial:

Of course there is also the "old-fashioned" python-oauth2 library, which is quite well-documented:

The documentation of the module contains an example of three-legged authentication for the Twitter API.

Concerning the redirect_url field: In general, you can use any URL you want here (even local addresses such as http://localhost/my/endpoint), the OAuth server will simply issue a HTTP 303 redirect request to the client after authenticating him, which is then processed on the client-side. However, some API services (such as Twitter) will require you to specify the redict_url beforehand and will refuse some URLs (e.g. IP-based ones).

If you're a fan of the requests Python library, I recommend using requests-oauthlib. It has great documentation and active developers.

Normally you setup the redirect_url in your application's settings on the API providers website. It looks like Pocket only supports browser based authentication, so you'll need a web browser to generate an access token that you can then embed in your script.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!