Tutorial for using requests_oauth2

后端 未结 2 1441
礼貌的吻别
礼貌的吻别 2020-12-28 10:17

I am trying to use the requests-oauth library for Python to make a request to Pocket. Unfortunately the description to use this library is not very comprehensive and I am al

相关标签:
2条回答
  • 2020-12-28 10:19

    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:

    • https://github.com/maraujop/requests-oauth2

    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:

    • http://apiwiki.poken.com/authentication/oauth2

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

    • https://github.com/simplegeo/python-oauth2

    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).

    0 讨论(0)
  • 2020-12-28 10:30

    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.

    0 讨论(0)
提交回复
热议问题