@@ -14,6 +14,8 @@ Which clients are used is entirely configurable.
1414 - Information about the ` plugin ` module and usage of.
1515- [ Available Clients] ( #available-clients )
1616 - Information about the clients provided by ` youtube-source ` , as well as their advantages/disadvantages.
17+ - [ Using OAuth tokens] ( #using-oauth-tokens )
18+ - Information on using OAuth tokens with ` youtube-source ` .
1719- [ Using a poToken] ( #using-a-potoken )
1820 - Information on using a ` poToken ` with ` youtube-source ` .
1921- [ Migration Information] ( #migration-from-lavaplayers-built-in-youtube-source )
@@ -58,8 +60,9 @@ Support for IP rotation has been included, and can be achieved using the followi
5860AbstractRoutePlanner routePlanner = new ...
5961YoutubeIpRotatorSetup rotator = new YoutubeIpRotatorSetup (routePlanner);
6062
63+ // 'youtube' is the variable holding your YoutubeAudioSourceManager instance.
6164rotator. forConfiguration(youtube. getHttpInterfaceManager(), false )
62- .withMainDelegateFilter(null ) // This is important, otherwise you may get NullPointerExceptions.
65+ .withMainDelegateFilter(youtube . getContextFilter()) // IMPORTANT
6366 .setup();
6467```
6568
@@ -206,6 +209,52 @@ Currently, the following clients are available for use:
206209 - ✔ Age-restricted video playback.
207210 - ❌ No playlist support.
208211
212+ # # Using OAuth Tokens
213+ You may notice that some requests are flagged by YouTube, causing an error message asking you to sign in to confirm you're not a bot.
214+ With OAuth integration, you can request that `youtube-source` use your account credentials to appear as a normal user, with varying degrees
215+ of efficacy. You can instruct `youtube-source` to use OAuth with the following :
216+
217+ > [!WARNING]
218+ > Similar to the `poToken` method, this is NOT a silver bullet solution, and worst case could get your account terminated!
219+ > For this reason, it is advised that **you use burner accounts and NOT your primary!**.
220+ > This method may also trigger ratelimit errors if used in a high traffic environment.
221+ > USE WITH CAUTION!
222+
223+ # ## Lavaplayer
224+ ` ` ` java
225+ YoutubeAudioSourceManager source = new YoutubeAudioSourceManager();
226+ // This will trigger an OAuth flow, where you will be instructed to head to YouTube's OAuth page and input a code.
227+ // This is safe, as it only uses YouTube's official OAuth flow. No tokens are seen or stored by us.
228+ source.useOauth2(null, false);
229+
230+ // If you already have a refresh token, you can instruct the source to use it, skipping the OAuth flow entirely.
231+ // You can also set the ` skipInitialization` parameter, which skips the OAuth flow. This should only be used
232+ // if you intend to supply a refresh token later on. You **must** either complete the OAuth flow or supply
233+ // a refresh token for OAuth integration to work.
234+ source.useOauth2("your refresh token", true);
235+ ```
236+
237+ <!-- TODO document rest routes -->
238+
239+ ### Lavalink
240+ ``` yaml
241+ plugins :
242+ youtube :
243+ enabled : true
244+ oauth :
245+ # setting "enabled: true" is the bare minimum to get OAuth working.
246+ enabled : true
247+
248+ # you may optionally set your refresh token if you have one, which skips the OAuth flow entirely.
249+ # once you have completed the oauth flow at least once, you should see your refresh token within your
250+ # lavalink logs, which can be used here.
251+ refreshToken : " your refresh token, only supply this if you have one!"
252+
253+ # Set this if you don't want the OAuth flow to be triggered, if you intend to supply a refresh token
254+ # later on via REST routes. Initialization is skipped automatically if a valid refresh token is supplied.
255+ skipInitialization : true
256+ ` ` `
257+
209258## Using a ` poToken`
210259A `poToken`, also known as a "Proof of Origin Token" is a way to identify what requests originate from.
211260In YouTube's case, this is sent as a JavaScript challenge that browsers must evaluate, and send back the resolved
0 commit comments