mirror of
https://github.com/FoxxMD/multi-scrobbler.git
synced 2026-04-30 04:39:57 +00:00
docs(ytmusic): Add new auth docs and update FAQ
This commit is contained in:
parent
e8716a45b2
commit
c33d42808a
3 changed files with 227 additions and 23 deletions
|
|
@ -721,30 +721,166 @@ After starting multi-scrobbler with credentials in-place open the dashboard (`ht
|
|||
|
||||
### [Youtube Music](https://music.youtube.com)
|
||||
|
||||
<details>
|
||||
:::warning
|
||||
|
||||
<summary>Migrating from YT Music cookie-based Source</summary>
|
||||
|
||||
In multi-scrobbler **below v0.9.0** YT Music credentials were extracted from browser cookies. Due to authentication inconsistency and YT service changes this was approach was dropped in favor of [oauth authentication which is more stable.](https://ytjs.dev/guide/authentication.html#youtube-tv-oauth2)
|
||||
|
||||
Your existing credentials cannot be migrated. However, the oauth approach is quite easy. Continue following the directions below to setup new authentication for your YT Music Source.
|
||||
|
||||
</details>
|
||||
|
||||
:::note
|
||||
|
||||
* Communication to YT Music is **unofficial** and not supported or endorsed by Google. This means that **this integration may stop working at any time** if Google decides to change how YT Music works in the browser.
|
||||
* Communication with YT Music is **unofficial** and not supported or endorsed by Google. This means that **this integration may stop working at any time** if Google decides to change how YT Music works in the browser.
|
||||
* Due to this scrobble history from YTM is often inconsistent and can cause missed scrobbles. [See the FAQ](../FAQ.md#youtube-music-misses-scrobbles) for a more detailed explanation.
|
||||
|
||||
:::
|
||||
|
||||
To authenticate simply start multi-scrobbler with an empty YT Music configuration. An authentication URL/code will be logged in additon to being available from the dashboard.
|
||||
#### Authentication
|
||||
|
||||
```
|
||||
[2024-10-09 15:24:17.358 -0400] INFO : [App] [Sources] [Ytmusic - MyYTM] ERROR: Sign in with the code 'CLV-KFA-BVKY' using the authentication link on the dashboard or https://www.google.com/device
|
||||
```
|
||||
Only one of these methods needs to be used. **Cookies** are easier but **OAuth Client** may be more stable.
|
||||
|
||||
Visit 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.
|
||||
<Tabs groupId="ytmAuth" queryString>
|
||||
<TabItem value="cookie" label="Cookies">
|
||||
:::info
|
||||
|
||||
If cookies stop working for you or are being invalidated often try switching to **OAuth Client** authentication.
|
||||
|
||||
:::
|
||||
|
||||
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](https://github.com/LuanRT/YouTube.js/issues/803#issuecomment-2504032666) to limit the chance the session is invalidated from normal browsing.
|
||||
|
||||
Add the cookie to your `ytmusic.json` config in `data`:
|
||||
|
||||
```json
|
||||
{
|
||||
"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.
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="oauth" label="OAuth Client">
|
||||
:::note
|
||||
|
||||
This is likely to be the most stable method and least likely to be blocked or have authentication invalidated after an extended period. It requires more setup but is worth the effort.
|
||||
|
||||
:::
|
||||
|
||||
[Based on the instructions from here...](https://github.com/LuanRT/YouTube.js/issues/803#issuecomment-2479689924)
|
||||
|
||||
* Login to [Google Cloud console](https://console.cloud.google.com/) (create an account, if necessary)
|
||||
* [Create a new project](https://console.cloud.google.com/projectcreate)
|
||||
* 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.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"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:
|
||||
|
||||
```
|
||||
Using Custom OAuth Client:
|
||||
Client ID: ...
|
||||
Client Secret: ...
|
||||
Redirect URI: http://localhost:9078/api/ytmusic/callback?name=MyYTM
|
||||
```
|
||||
|
||||
If the beginning of the URL (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](https://foxxmd.github.io/multi-scrobbler/docs/configuration/#base-url) or you can provide your own (Custom) Redirect URI for MS to use by setting it in `ytmusic.json`.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Using a Custom Redirect URI</summary>
|
||||
|
||||
The three parts of the URL that must be the same:
|
||||
|
||||
* it must start with `api` (after domain or subdirectory IE `my.domain.tld/api...` or `whatever.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!
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "ytmusic",
|
||||
"enable": true,
|
||||
"name": "MyYTM",
|
||||
"data": {
|
||||
"clientId": "8910....6jqupl.apps.googleusercontent.com",
|
||||
"clientSecret": "GOCSPX-WGXL6BSuQ343...",
|
||||
"redirectUri": "http://my.custom.domain/api/ytmusic/callback?name=MyYTM"
|
||||
},
|
||||
"options": {
|
||||
"logAuthUpdateChanges": true,
|
||||
"logDiff": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
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.
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="ytt" label="YoutubeTV">
|
||||
|
||||
:::warning
|
||||
|
||||
Using the built-in YoutubeTV authentication is unlikely to work due to [Google restricting what permissions TV clients can have](https://github.com/yt-dlp/yt-dlp/issues/11462#issuecomment-2471703090). This authentication method should not be used.
|
||||
|
||||
:::
|
||||
|
||||
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/device
|
||||
```
|
||||
|
||||
Visit 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.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
#### Configuration
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue