Skip to content

Support OAuth2 Account Integration - #33

Merged
devoxin merged 15 commits into
mainfrom
feat/oauth-integration
Aug 19, 2024
Merged

Support OAuth2 Account Integration#33
devoxin merged 15 commits into
mainfrom
feat/oauth-integration

Conversation

@devoxin

@devoxin devoxin commented Jul 12, 2024

Copy link
Copy Markdown
Member

This PR implements support for linking accounts via OAuth2.

By acting as a TV client, we can request users input a code into the official device linking webpage which grants us an access token and a refresh token, which with the former, can be dispatched with requests effectively serving as a replacement to the original source manager's account authentication system. The entire process is done without any external hosted services so security is vastly improved, and this relies on the OAuth flow provided by YT/Google.

The downside to this system is it requires users to keep track of refresh tokens, or authorize youtube-source on every launch.
There are facilities provided to fetch and set refresh tokens to allow for some form of persistence.

This PR requires a few finer details to be worked out, notably:

  • what happens if an invalid refresh token is provided? This should be handled gracefully, and begin the OAuth process anew.
  • REST endpoints require testing.
  • REST endpoints require some form of locking to avoid users making POST requests to update refresh tokens whilst an OAuth initialisation/refresh process is occurring.
  • Documenting the new endpoints and config properties.

The basic functionality of this PR has been tested, and account authentication does work, with authorization headers being appended onto relevant requests. Testing has not been done to ensure the success of token refreshing as of yet. I also cannot confirm whether providing authentication alleviates any current issues such as "Sign in to confirm you're not a bot" or accessing age restricted videos that the embedded TV client does not provide access to.

A big, or rather, VERY BIG disclaimer to this PR is to use with caution. DO NOT use your main account(s).

@ghost

ghost commented Jul 18, 2024

Copy link
Copy Markdown

Hello,

I wanted to write an issue but maybe this pull request will resolve the problem.

I'm just wondering if this PR is related to the " {'message': 'This video requires login.', 'severity': 'common', 'cause': 'com.sedmelluq.discord.lavaplayer.tools.FriendlyException: This video requires login.'} " error.

Thanks for your answer.

@devoxin

devoxin commented Jul 18, 2024

Copy link
Copy Markdown
Member Author

It should, as well as Sign in to confirm you're not a bot. But I should ask — are you trying to play an age restricted video? If so, do you have the TV client enabled?

@ghost

This comment was marked as off-topic.

@devoxin

This comment was marked as off-topic.

@ghost

This comment was marked as off-topic.

@devoxin

This comment was marked as off-topic.

@ghost

This comment was marked as off-topic.

@devoxin

This comment was marked as off-topic.

@devoxin
devoxin force-pushed the feat/oauth-integration branch 2 times, most recently from 119711e to 9e234eb Compare July 31, 2024 23:11
@ghost

ghost commented Aug 3, 2024

Copy link
Copy Markdown

Just tested this PR, seems to fix "sign in to confirm you are not a robot" on a Hetzner node and the 403 errors I was getting on my locally hosted node. I don't even have to have IPv6 rotation on. Thank you for this, you are genuinely a lifesaver. I was having so much trouble with the 403 errors.

@makarasty

This comment was marked as outdated.

@devoxin

This comment was marked as resolved.

@makarasty

This comment was marked as resolved.

@devoxin

This comment was marked as outdated.

@somboytiger

Copy link
Copy Markdown

It seems that the issue with using IPv6 on Hetzner was only temporarily resolved. After using it with 30-50 players for 10 days, the problem 'Your limits will reset soon, usually within an hour.' followed."

@ghost

ghost commented Aug 6, 2024

Copy link
Copy Markdown

what do I need to add to the configuration to make it work?

Change your dependency to look like this:

lavalink:
  plugins:
    - dependency: "dev.lavalink.youtube:youtube-plugin:9e234eb0ef4e4c926ffd3a76ae78ae3102c1dbb5" # This is the sha of the latest commit in this pr
      snapshot: true # due to it being a commit, enable snapshot (i think)

Add this line to your youtube config:

plugins:
  youtube:
    oauthConfig: 
      enabled: true # Default disabled

Launch Lavalink like normal and look at it's logs. Further instruction will be there.

For now, this works very well and solved all the problems I had with authorization errors. However, it is a very bare bones addition.

@makarasty

This comment was marked as outdated.

@devoxin

This comment was marked as outdated.

@makarasty

This comment was marked as outdated.

@devoxin
devoxin force-pushed the feat/oauth-integration branch from 6171f77 to 6af80f4 Compare August 15, 2024 20:20
@devoxin devoxin added the enhancement New feature or request label Aug 15, 2024
@devoxin devoxin linked an issue Aug 15, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YouTube: Sign in to confirm you’re not a bot

3 participants