Requestsに対するOAuthlib 認証のサポートに対応するライブラリ「requests-oauthlib」のインストールについて解説しています。
「requests-oauthlib(https://github.com/requests/requests-oauthlib,https://requests-oauthlib.readthedocs.org/)」は、Requestsライブラリと OAuthlibライブラリを使用して、OAuth1 および OAuth2 クライアントを構築するための使いやすいインターフェイスを提供している。
■Python
今回のPythonのバージョンは、「3.9.9」を使用しています。(Windows11)(pythonランチャーでの確認)
■requests-oauthlibをインストールする
requests-oauthlibをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。
pip install requests-oauthlib
起動後、上記のコマンドを入力し、Enterキーを押します。
なお、今回は、pythonランチャーを使用しており、Python Version 3.9.9にインストールを行うために、バージョンの切り替えを行います。
py -3.9 -m pip install requests-oauthlib
切り替えるために、上記のコマンドを入力し、Enterキーを押します。
Defaulting to user installation because normal site-packages is not writeable Collecting requests-oauthlib Using cached requests_oauthlib-1.3.1-py2.py3-none-any.whl (23 kB) Collecting oauthlib>=3.0.0 Using cached oauthlib-3.2.2-py3-none-any.whl (151 kB) Collecting requests>=2.0.0 Using cached requests-2.31.0-py3-none-any.whl (62 kB) Collecting certifi>=2017.4.17 Using cached certifi-2023.7.22-py3-none-any.whl (158 kB) Collecting urllib3<3,>=1.21.1 Using cached urllib3-2.0.4-py3-none-any.whl (123 kB) Collecting idna<4,>=2.5 Using cached idna-3.4-py3-none-any.whl (61 kB) Collecting charset-normalizer<4,>=2 Using cached charset_normalizer-3.2.0-cp39-cp39-win_amd64.whl (96 kB) Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests, oauthlib, requests-oauthlib WARNING: The script normalizer.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed certifi-2023.7.22 charset-normalizer-3.2.0 idna-3.4 oauthlib-3.2.2 requests-2.31.0 requests-oauthlib-1.3.1 urllib3-2.0.4 WARNING: You are using pip version 21.2.4; however, version 23.2.1 is available. You should consider upgrading via the 'C:\Program Files\Python39\python.exe -m pip install --upgrade pip' command.
Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、requests-oauthlibが正常にインストールされたことになりますが、「WARNING」と表示されました。「WARNING」はエラーではなく警告で、インストールは行われているので、今回は一旦無視しています。
なお、今回はrequests-oauthlibのバージョン1.3.1をインストールしました。
コメント