Youtube Music
Authentication
Section titled “Authentication”Only one of these methods needs to be used.
Use instructions from
- https://github.com/patrickkfkan/Volumio-YouTube.js/wiki/How-to-obtain-Cookie or
- https://ytmusicapi.readthedocs.io/en/stable/setup/browser.html#copy-authentication-headers
to get the Cookie value from a browser.
It is highly recommended to get the cookie from an Incognito/Private Session to limit the chance the session is invalidated from normal browsing.
Add the cookie to your ytmusic.json config in data or as an ENV:
{ "type": "ytmusic", "enable": true, "name": "MyYTM", "data": { "cookie": "__Secure-1PSIDTS=sidts-CjEB3EgAEvCd-......" }, "options": { "logAuthUpdateChanges": true, "logDiff": true }}If MS gives you authentication errors (session invalidated) at some point in the future follow the same instructions to get new cookies.
Based on the instructions from here…
- Login to Google Cloud console (create an account, if necessary)
- Go to APIs and services.
- Configure the OAuth consent screen
- Use the old experience if possible
- If new is unavoidable then do not fill out any branding and under Authorized Domains you can delete the empty one (in order to save)
- Add yourself as an authorized user
- Navigate to Credentials
- Create Credentials -> choose “OAuth client ID”
- Application Type is Web Application
- Name is whatever you want, leave Authorization Javascript origins blank
- Authorized redirect URIs
- This must be exactly the same as what is displayed in MS! For now leave it blank so we can generate it from MS first
- Create
- In the newly created client popup save the Client ID and Client Secret, then copy them into
ytmusic.jsonor appropriate ENVs:
- In the newly created client popup save the Client ID and Client Secret, then copy them into
- Create Credentials -> choose “OAuth client ID”
- Configure the OAuth consent screen
{ "type": "ytmusic", "enable": true, "name": "MyYTM", "data": { "clientId": "8910....6jqupl.apps.googleusercontent.com", "clientSecret": "GOCSPX-WGXL6BSuQ343..." }, "options": { "logAuthUpdateChanges": true, "logDiff": true }}Now, start MS and during the YTMusic startup it will log something like this:
Will use custom OAuth Client:Client ID: ...Client Secret: ...Redirect URI: http://YOUR_MS_DOMAIN/api/ytmusic/callback?name=MyYTMIf the beginning of the Redirect URI (before api) is EXACTLY how you would reach the MS dashboard from your browser (EX http://localhost:9078) then edit your google oauth client section for Authorized redirect URIs and add the URL MS has displayed.
If it is NOT EXACTLY the same you either need to set MS’s base url or you can provide your own (Custom) Redirect URI for MS to use by setting it in ytmusic.json or ENV.
Using a Custom Redirect URI
The three parts of the URL that must be the same:
- it must start with
api(after domain or subdirectory IEmy.domain.tld/api...orwhatever.tld/subDir/api... - it must end in
ytmusic/callback - It must include
name=[NameOfSource]in the query string
Remember to add your custom URL to the Authorized redirect URIs section in the google oauth client!
{ "type": "ytmusic", "enable": true, "name": "MyYTM", "data": { "clientId": "8910....6jqupl.apps.googleusercontent.com", "clientSecret": "GOCSPX-WGXL6BSuQ343...", "redirectUri": "http://YOUR_MS_DOMAIN/api/ytmusic/callback?name=MyYTM" }, "options": { "logAuthUpdateChanges": true, "logDiff": true }}AFTER changing the Authorized redirect URIs on Google Cloud console you may need to wait a few minutes for it to take affect. Then restart MS. From the dashboard click (Re)authenticate on the YTmusic source card and follow the auth flow:
- On the screen about “testing” make sure you hit Continue (not Back To Safety)
- Make sure to select ALL scopes/permissions/grants it asks you about
Select what [YourAppName] can access-> Select all
Once the flow is finished MS will get the credentials and start polling automatically. You should not need to re-authenticate again after restarting MS as it saves the credentials to the /config folder.
To authenticate start multi-scrobbler with an empty YT Music configuration. An authentication URL/code will be logged in additon to being available from the dashboard.
ERROR: Sign in with the code 'CLV-KFA-BVKY' using the authentication link on the dashboard or https://www.google.com/deviceVisit the authentication URL and enter the code that was provided (also available on the dashboard). After completing the setup flow MS will log Auth success and the YT Music dashboard card will display as Idle after refreshing. Click the Start link to begin monitoring.
Configuration
Section titled “Configuration”Session Options
For File and AIO config, innerTubeOptions is an optional property you can use to tailor SessionOptions from ytjs.dev, for YTM.
innerTubeOptions shown in the schema explorer documents some of the properties that may be relevant to your multi-scrobbler experience but you can pass any of the properties found in SessionOptions to innerTubeOptions.
Configuration Type
This is configuration for the ENV Config Type.
| Environmental Variable | Type | Default | Description |
|---|---|---|---|
YTM_ID |
string | A globally unique ID EX myComponentId |
|
YTM_NAME |
string | Value of YTM_ID |
A vanity name EX My Cool Component |
YTM_ENABLE |
boolean | true | Should this component be used? |
YTM_REDIRECT_URI |
string | Google Cloud Console project OAuth Client Authorized redirect URI | |
YTM_CLIENT_ID |
string | Google Cloud Console project OAuth Client ID | |
YTM_CLIENT_SECRET |
string | Google Cloud Console project OAuth Client Secret | |
YTM_COOKIE |
string | The cookie retrieved from the Request Headers of music.youtube.com after logging in. |
Bold/Italic = Required
Config Structure
This displays the structure of the File Configuration for a ytmusic type Source with all possible properties, their shape, and descriptions/types. Use this to understand how to write a valid config.
Config Example
This displays an example config file of a ytmusic Source File Configuration that adheres to the shown Config Structure.
- text mode lets you edit the JSON directly.
- tree mode gives you a guided point-and-click editing experience that always keeps the JSON syntax valid.
Both modes validate that the configuration is correct. Any errors show up as squiggly lines.
After you finish editing, switch to text and then copy all text to get a completed config.
Config Example Mobile Experience
This displays an example config file of a ytmusic Source File Configuration that adheres to the shown Config Structure.
The example config file editor is meant for a larger screen experience so only the read-only example is shown. Please use this site on a tablet/laptop/desktop to enable file editor features.
[ { "id": "myYtMusic", "name": "Foxx YT Music", "data": { "cookie": "__Secure-1PSIDTS=sidts-CjEB3EgAEvCd-......", "clientId": "891098404....apps.googleusercontent.com", "clientSecret": "GOCS..." }, "enable": true, "clients": [], "options": { "logDiff": true } }]Config Structure
This displays the structure of the all-in-one (config.json) configuration with all possible properties, their shape, and descriptions/types. Use this to understand how to write a valid config.
Select the ytmusic type from the respective sources node below, then expand it.
Config Example
This displays an example config file of a all-in-one (config.json) configuration that includes a ytmusic Source that adheres to the shown Config Structure.
- text mode lets you edit the JSON directly.
- tree mode gives you a guided point-and-click editing experience that always keeps the JSON syntax valid.
Both modes validate that the configuraion is correct. Any errors show up as squiggly lines.
After you finish editing, switch to text and then copy all text to get a completed config.
Config Example Mobile Experience
This displays an example config file of a all-in-one (config.json) configuration that includes a ytmusic Source that adheres to the shown Config Structure.
The example config file editor is meant for a larger screen experience so only the read-only example is shown. Please use this site on a tablet/laptop/desktop to enable file editor features.
{ "sources": [ { "type": "ytmusic", "id": "myYtMusic", "name": "Foxx YT Music", "data": { "cookie": "__Secure-1PSIDTS=sidts-CjEB3EgAEvCd-......", "clientId": "891098404....apps.googleusercontent.com", "clientSecret": "GOCS..." }, "enable": true, "clients": [], "options": { "logDiff": true } } ]}