-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ytm): Re-implement auth with cookie and oauth #236
Conversation
Youtube TV seems no longer have scope for reading history or account details? Cookie may work and custom oauth seems most stable based on reporting from LuanRT/YouTube.js#803
If you are testing this:
Cookie AuthWorks for now but this is likely to be the least stable option. 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. It is 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 {
"type": "ytmusic",
"enable": true,
"name": "MyYTM",
"data": {
"cookie": "__Secure-1PSIDTS=sidts-CjEB3EgAEvCd-......"
},
"options": {
"logAuthUpdateChanges": true,
"logDiff": true
}
} Custom OAuthThis is likely to be more stable but takes more setup than cookies. If you can, this is the recommended approach. Base on the instructions from here...
{
"type": "ytmusic",
"enable": true,
"name": "MyYTM",
"data": {
"clientId": "8910....6jqupl.apps.googleusercontent.com",
"clientSecret": "GOCSPX-WGXL6BSuQ343..."
},
"options": {
"logAuthUpdateChanges": true,
"logDiff": true
}
} NOTE: If you have an existing YTM credentials folder in your Now, start MS and during the YTMusic startup it will log something like this:
If the beginning of the URL (before If it is NOT EXACTLY the same you either need to set MS's base url or you can provide a redirect URI for MS to use by setting it in The two parts of the URL that must be the same:
Remember to add your custom URL to the {
"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
}
} AFTER setting the google client redirect URI and restarting MS (if you made changes) wait a few minutes. Then restart MS. From the dashboard click
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 |
Good evening, Moving to this thread, as requested. First test with the cookie approach: worked as seamless as before. Second test with the new oauth approach: error once authorizing past the oauth page "No page for /ytmusic/callback%3Fname=MyYTM exists!" I did initially try the custom URI with my duckdns domain, but it stalled out entirely, so I reverted just to using the localhost to test this configuration. I do notice that my redirect URI is "...callback%#Fname%" and your example is "callback?name". Maybe that contributes? Let me know what else I can provide/test help! |
@jrlebbs can you give me more specifics about the conditions these things happened under? Please provide the EDIT: I have pushed a change to the default redirectUri generation that may fix your issue. Please pull the latest |
@xathon thanks for the feedback. Can you try replacing |
Forgot to mention, I actually did that. Google then told me that the redirect URL doesn't match. |
Hey @FoxxMD, I am having the same behavior as @xathon . After following the steps to set up Oauth, and clicking auth, I got to the Google page for the permissions, then accepted the risk of the testing app, but then got redirected to a url within my MS installation saying "Not Found" (aka 400). I then modified the %3F with ? and now google is complaining about the url not matching the Authorized redirect URIs. So, I went back to the Google console, and added a second URL under Authorized redirect URIs with the URL using the question mark. After that, the MS page I am redirected to from the Google authorization process says "OK". I can se the logs now showing tracks discovered in YT Music! |
I can confirm that MS is now scrobbling YTMusic again! Thanks a lot @FoxxMD ! |
I did find that after changing the auth URL it takes google cloud at least a few minutes for the change to take affect.
EDIT: redirect uri query string should be fixed in the latest image. |
Can confirm, that works! Thanks! |
I was having the same issues as above users when trying to use oauth yesterday. Today I skipped oauth and went right to cookie auth and everything worked great. |
Here's my update. Pulled the latest build of pr-236. Attempt 1: No custom URI, just used the localhost URI generated by MS. Worked amazing! Attempt 2: custom domain URI: confirmed that i put it in the google cloud redirect uri as well: Verbose logs attached. |
* Fixes parsing warning for history response
The newest image should now allow re-authenticating and will also verify the validity of a custom redirect uri |
it worked!! no issues at this point! |
Newest image supports ENV config:
|
What a PIA...That being said..Thank you @FoxxMD for your work on this. I got mine working... |
📦 A new release has been made for this pull request.To play around with this PR, pull an image:
Images are available for x86_64 and ARM64.
|
Checklist before requesting a review
Type of change
Please delete options that are not relevant.
Describe your changes
Youtube TV seems no longer have scope for reading history or account details. Cookies may work and custom oauth seems most stable based on reporting from LuanRT/YouTube.js#803
TODO
Issue number and link, if applicable
#195
#229
#203