pythonでOAuth認証をするときに便利なライブラリ

2016.5.29

OAuth認証をpythonで行うために。

% sudo pip install requests requests_oauthlib
The directory '/Users/XXXXXXXX/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/XXXXXXXX/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting requests
 Downloading requests-2.10.0-py2.py3-none-any.whl (506kB)
   100% |████████████████████████████████| 512kB 796kB/s
Collecting requests_oauthlib
 Downloading requests_oauthlib-0.6.1-py2.py3-none-any.whl
Collecting oauthlib>=0.6.2 (from requests_oauthlib)
Installing collected packages: requests, oauthlib, requests-oauthlib
Successfully installed oauthlib-1.1.1 requests-2.10.0 requests-oauthlib-0.6.1

使えるかどうか確認。

% python
Python 2.7.11 (default, Dec 15 2015, 01:36:10)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from requests_oauthlib import OAuth1Session
>>>

OK使えた。

こちらで公開されているようです。

https://github.com/requests/requests-oauthlib

Related.