Package dev.lavalink.youtube.http
Class YoutubeOauth2Handler
java.lang.Object
dev.lavalink.youtube.http.YoutubeOauth2Handler
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionYoutubeOauth2Handler(com.sedmelluq.discord.lavaplayer.tools.io.HttpInterfaceManager httpInterfaceManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyToken(org.apache.http.client.methods.HttpUriRequest request) voidapplyToken(org.apache.http.client.methods.HttpUriRequest request, String token) com.sedmelluq.discord.lavaplayer.tools.JsonBrowsercreateNewAccessToken(String refreshToken) Executes the HTTP request to refresh the access token and returns the response.com.sedmelluq.discord.lavaplayer.tools.JsonBrowserRetrieves a device code for use with the OAuth flow.com.sedmelluq.discord.lavaplayer.tools.JsonBrowserfetchRefreshToken(String deviceCode) Retrieve a refresh token from a given device code.@Nullable StringbooleanbooleanisOauthFetchContext(org.apache.http.client.protocol.HttpClientContext context) voidrefreshAccessToken(boolean force) Refreshes an access token using a supplied refresh token.voidsetRefreshToken(@Nullable String refreshToken, boolean skipInitialization) boolean
-
Field Details
-
OAUTH_INJECT_CONTEXT_ATTRIBUTE
- See Also:
-
-
Constructor Details
-
YoutubeOauth2Handler
public YoutubeOauth2Handler(com.sedmelluq.discord.lavaplayer.tools.io.HttpInterfaceManager httpInterfaceManager)
-
-
Method Details
-
setRefreshToken
-
hasAccessToken
public boolean hasAccessToken() -
shouldRefreshAccessToken
public boolean shouldRefreshAccessToken() -
getRefreshToken
-
isOauthFetchContext
public boolean isOauthFetchContext(org.apache.http.client.protocol.HttpClientContext context) -
fetchDeviceCode
public com.sedmelluq.discord.lavaplayer.tools.JsonBrowser fetchDeviceCode()Retrieves a device code for use with the OAuth flow. The returned payload will contain a user code and a device code, as well as a recommended poll interval, which must be used to complete the flow. -
fetchRefreshToken
public com.sedmelluq.discord.lavaplayer.tools.JsonBrowser fetchRefreshToken(String deviceCode) throws IOException Retrieve a refresh token from a given device code. This might not yield a successful response if the OAuth flow for the given device code has not yet been completed, or the device code is invalid.- Parameters:
deviceCode- The device code obtained fromfetchDeviceCode()- Throws:
IOException
-
refreshAccessToken
public void refreshAccessToken(boolean force) Refreshes an access token using a supplied refresh token.- Parameters:
force- Whether to forcefully renew the access token, even if it doesn't necessarily need to be refreshed yet.
-
createNewAccessToken
Executes the HTTP request to refresh the access token and returns the response.- Parameters:
refreshToken- The refresh token to be included in the request.- Returns:
- The JSON response as a JsonObject.
-
applyToken
public void applyToken(org.apache.http.client.methods.HttpUriRequest request) -
applyToken
-