java.lang.Object
dev.katsute.mal4j.MyAnimeListAuthenticator
Documentation: https://myanimelist.net/apiconfig/references/authorization
The authenticator is used to retrieve OAuth2 tokens given a client id and client secret.
MyAnimeList can be authenticated by with either:
The authenticator is used to retrieve OAuth2 tokens given a client id and client secret.
MyAnimeList can be authenticated by with either:
- An authorization code using
MyAnimeListAuthenticator(Authorization)
. - A local server using
MyAnimeListAuthenticator.LocalServerBuilder
.
- Since:
- 1.0.0
- Version:
- 2.11.0
- Author:
- Katsute
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Creates a MyAnimeList Authenticator by deploying a local server to authenticate the user. -
Constructor Summary
ConstructorDescriptionMyAnimeListAuthenticator
(Authorization authorization) Creates an authenticator.MyAnimeListAuthenticator
(Authorization authorization, AccessToken token) Creates an authenticator. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returns if Java has permission to open the client browser.static String
generatePKCE
(int length) final AccessToken
Returns the access token.final Authorization
static String
getAuthorizationURL
(String client_id, String PKCE_code_challenge) Returns the authorization URL for a client id.static String
getAuthorizationURL
(String client_id, String PKCE_code_challenge, String redirect_URI) Returns the authorization URL for a client id.static String
getAuthorizationURL
(String client_id, String PKCE_code_challenge, String redirect_URI, String state) Returns the authorization URL for a client id.final AccessToken
Refreshes the access token.final String
toString()
-
Constructor Details
-
MyAnimeListAuthenticator
Creates an authenticator.- Parameters:
authorization
- authorization- Throws:
InvalidTokenException
- if token is expired or invalid- Since:
- 2.7.0
- See Also:
-
MyAnimeListAuthenticator
Creates an authenticator.- Parameters:
authorization
- authorizationtoken
- token (optional, use an existing access token)- Throws:
InvalidTokenException
- if token is expired or invalid- Since:
- 2.7.0
- See Also:
-
-
Method Details
-
getAuthorization
-
getAccessToken
Returns the access token.- Returns:
- access token
- Since:
- 1.0.0
- See Also:
-
refreshAccessToken
Refreshes the access token. This does not refresh the token inside the MyAnimeList object, you must useMyAnimeList.refreshToken()
instead.- Returns:
- updated access token
- Since:
- 1.0.0
- See Also:
-
getAuthorizationURL
Returns the authorization URL for a client id.- Parameters:
client_id
- client id (required)PKCE_code_challenge
- PKCE code challenge (required)- Returns:
- authorization URL
- Throws:
NullPointerException
- if client ID or PKCE is null- Since:
- 1.0.0
- See Also:
-
getAuthorizationURL
public static String getAuthorizationURL(String client_id, String PKCE_code_challenge, String redirect_URI) Returns the authorization URL for a client id.- Parameters:
client_id
- client id (required)PKCE_code_challenge
- PKCE code challenge (required)redirect_URI
- preregistered URI, only needed if you want to select a specific application redirect URI (optional)- Returns:
- authorization URL
- Throws:
NullPointerException
- if client ID or PKCE is null- Since:
- 1.0.0
- See Also:
-
getAuthorizationURL
public static String getAuthorizationURL(String client_id, String PKCE_code_challenge, String redirect_URI, String state) Returns the authorization URL for a client id.- Parameters:
client_id
- client id (required)PKCE_code_challenge
- PKCE code challenge (required)redirect_URI
- preregistered URI, only needed if you want to select a specific application redirect URI (optional)state
- 0Auth2 state (optional)- Returns:
- authorization URL
- Throws:
NullPointerException
- if client ID or PKCE is null- Since:
- 1.0.0
- See Also:
-
canOpenBrowser
public static boolean canOpenBrowser()Returns if Java has permission to open the client browser.- Returns:
- if Java can open the browser
- Since:
- 1.0.0
-
generatePKCE
-
toString
-