Use subsonic API with python3

A memo that investigated how to use the subsonic API When using Basic authentication, note that you cannot use the method of authenticating after returning the 401 code from the server. I think it's okay to use u and p parameters because they aren't encrypted anyway, but what about?

python


import httplib2
import base64

httplib2.debuglevel = 1 #debug output ON
h = httplib2.Http('.cache') #Of the argument.cache is the cache storage directory

top_level_url = 'http://my_server/'
url = top_level_url + 'rest/ping.view?v=1.8.0&c=myapp'

user_id = 'id'
passwd = 'pw'

encoded = str(base64.b64encode(bytes(user_id + ':' + passwd ,'utf8')),'utf-8') #base64 conversion

_headers={'Authorization':'Basic '+ encoded} 
response, content = h.request(url,headers=_headers)

I also learned about httplib2.

Referenced site http://diveintopython3-ja.rdy.jp/http-web-services.html

Recommended Posts

Use subsonic API with python3
Use Trello API with python
Use Twitter API with Python
[Python] Use JSON with Python
Use mecab with Python3
Use DynamoDB with Python
Use Python 3.8 with Anaconda
Use python with docker
Use TUN / TAP with Python
Web API with Python + Falcon
Play RocketChat with API / Python
Call the API with python3.
Use e-Stat API from Python
Python: How to use async with
Use PointGrey camera with Python (PyCapture2)
Create Awaitable with Python / C API
Get reviews with python googlemap api
Run Rotrics DexArm with python API
[Python] Use Basic/Digest authentication with Flask
Quine Post with Qiita API (Python)
Use NAIF SPICE TOOLKIT with Python
Use rospy with virtualenv in Python3
Hit the Etherpad-lite API with Python
[python] Read information with Redmine API
Use kabu StationĀ® API from Python
Use Python in pyenv with NeoVim
Use Windows 10 speech synthesis with Python
Use OpenCV with Python 3 in Window
Use PostgreSQL with Lambda (Python + psycopg2)
[Python] How to use Typetalk API
Use Google Analytics API from Python
Easy to use Nifty Cloud API with botocore and python
Collecting information from Twitter with Python (Twitter API)
FizzBuzz with Python3
Scraping with Python
Automatically create Python API documentation with Sphinx
Statistics with python
Use smbus with python3 under pyenv environment
Use DeepL with python (for dissertation translation)
Simple Slack API client made with Python
Scraping with Python
Python with Go
[September 2020 version] Explains the procedure to use Gmail API with Python
Twilio with Python
Integrate with Python
[Python] Use string data with scikit-learn SVM
Sample to use after OAuth authentication of BOX API with Python
Play with 2016-Python
[Introduction to Python] Let's use foreach with Python
Use PIL and Pillow with Cygwin Python
AES256 with python
Use cryptography library cryptography with Docker Python image
Tested with Python
Use Google Cloud Vision API from Python
python starts with ()
Use JIRA API
with syntax (Python)
Use Application Insights with Python 3 (including bottles)
Bingo with python
[Python] Quickly create an API with Flask
Zundokokiyoshi with python