Skip to content
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

Implement YouTube OAuth2 login #1670

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Implement YouTube OAuth2 login #1670

wants to merge 4 commits into from

Conversation

MichailiK
Copy link
Collaborator

This pull request...

  • Fixes a bug
  • Introduces a new feature
  • Improves an existing feature
  • Boosts code quality or performance

Description

This PR adds a toggle to enable the OAuth2 capability found in the YouTube source manager. It also automatically stores & retrieves the refresh token for convenience of JMusicBot users (as the source manager does not do that itself.)

Quick summary of the login flow

Upon enabling OAuth2 (youtubeoauth2=true in the config.txt) the YouTube source manager will log the following:

[13:41:00] [INFO] [YoutubeOauth2Handler]: ==================================================
[13:41:00] [INFO] [YoutubeOauth2Handler]: !!! DO NOT AUTHORISE WITH YOUR MAIN ACCOUNT, USE A BURNER !!!
[13:41:00] [INFO] [YoutubeOauth2Handler]: OAUTH INTEGRATION: To give youtube-source access to your account, go to https://www.google.com/device and enter code ABC-DEF-GHI
[13:41:00] [INFO] [YoutubeOauth2Handler]: !!! DO NOT AUTHORISE WITH YOUR MAIN ACCOUNT, USE A BURNER !!!
[13:41:00] [INFO] [YoutubeOauth2Handler]: ==================================================

Navigating to https://www.google.com/device and entering the code will lead you to an OAuth2 page

OAuth2 page

(the source manager pretends to be a logged in TV client to play tracks)

Once allowed, the source manager logs a refresh token. For convenience, JMusicBot intercepts the log with a turbo filter & stores the refresh token as a file, youtubetoken.txt. The refresh token will be used when JMusicBot gets restarted to retrieve an access token.

Purpose

This should circumvent the "Sign in to confirm you're not a bot" message that people (particularly) on servers have been getting.

Relevant Issue(s)

Fixes #1588

Todo

  • The GUI can't seem to log the messages from the OAuth2 handler, they always end up in stdout. Have to yet look into why

@MichailiK MichailiK mentioned this pull request Aug 24, 2024
@chenchuuu
Copy link

It did not works for me. I cloned this branch and after executed run_jmusicbot.sh, in my config.txt did not appear the option youtubeoauth2

@MichailiK
Copy link
Collaborator Author

JMusicBot does not alter existing config files. You will need to manually add youtubeoauth2=true to your config.txt file.

@chenchuuu
Copy link

JMusicBot does not alter existing config files. You will need to manually add youtubeoauth2=true to your config.txt file.

I have just did it, but after executed the .sh, youtubesource did not show me this log:

[13:41:00] [INFO] [YoutubeOauth2Handler]: ==================================================
[13:41:00] [INFO] [YoutubeOauth2Handler]: !!! DO NOT AUTHORISE WITH YOUR MAIN ACCOUNT, USE A BURNER !!!
[13:41:00] [INFO] [YoutubeOauth2Handler]: OAUTH INTEGRATION: To give youtube-source access to your account, go to https://www.google.com/device and enter code ABC-DEF-GHI
[13:41:00] [INFO] [YoutubeOauth2Handler]: !!! DO NOT AUTHORISE WITH YOUR MAIN ACCOUNT, USE A BURNER !!!
[13:41:00] [INFO] [YoutubeOauth2Handler]: ==================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Sign in to confirm you’re not a bot." error with YouTube videos
2 participants