java.lang.Object
dev.katsute.mal4j.MyAnimeListAuthenticator.LocalServerBuilder
- Enclosing class:
MyAnimeListAuthenticator
Creates a MyAnimeList Authenticator by deploying a local server to authenticate the user.
- Since:
- 1.1.0
- Version:
- 2.4.0
- Author:
- Katsute
- See Also:
-
Constructor Summary
ConstructorDescriptionLocalServerBuilder
(String client_id, int port) Instantiates a local server builder with a client id and port.LocalServerBuilder
(String client_id, String client_secret, int port) Instantiates a local server builder with a client id, client secret, and port. -
Method Summary
Modifier and TypeMethodDescriptionfinal MyAnimeListAuthenticator
build()
Returns the built authenticator.Indicates that the authorization page should be opened in the user's browser automatically.openBrowser
(boolean openBrowser) If true, a browser will automatically be opened to the authorization page.setRedirectURI
(String redirectURI) Sets the application redirect URI.setResponseHandler
(AuthResponseHandler responseHandler) Sets the response handler.setTimeout
(int timeout) Sets how long (in seconds) that the server will expire in.setURLCallback
(Consumer<String> consumer) Sets the auth URL callback method.final String
toString()
-
Constructor Details
-
LocalServerBuilder
Instantiates a local server builder with a client id and port.- Parameters:
client_id
- client idport
- port- Since:
- 1.1.0
- See Also:
-
LocalServerBuilder
Instantiates a local server builder with a client id, client secret, and port.- Parameters:
client_id
- client idclient_secret
- client secretport
- port- Since:
- 1.1.0
- See Also:
-
-
Method Details
-
openBrowser
Indicates that the authorization page should be opened in the user's browser automatically.- Returns:
- builder
- Since:
- 1.1.0
- See Also:
-
openBrowser
If true, a browser will automatically be opened to the authorization page. Note that if this is false you will have to go to the page manually usingMyAnimeListAuthenticator.getAuthorizationURL(String, String)
,MyAnimeListAuthenticator.getAuthorizationURL(String, String, String)
, orMyAnimeListAuthenticator.getAuthorizationURL(String, String, String, String)
.- Parameters:
openBrowser
- if browser should be opened- Returns:
- builder
- Since:
- 1.1.0
- See Also:
-
setTimeout
Sets how long (in seconds) that the server will expire in. Once the timeout has passed a new authentication builder must be used.- Parameters:
timeout
- server timeout- Returns:
- builder
- Since:
- 1.1.0
-
setRedirectURI
Sets the application redirect URI. Only required if your application has more than one redirect URI registered.- Parameters:
redirectURI
- redirect URI- Returns:
- builder
- Since:
- 1.1.0
-
setResponseHandler
public final MyAnimeListAuthenticator.LocalServerBuilder setResponseHandler(AuthResponseHandler responseHandler) Sets the response handler.- Parameters:
responseHandler
- response handler- Returns:
- builder
- Since:
- 1.1.0
- See Also:
-
setURLCallback
Sets the auth URL callback method. Used to retrieve the URL that generates the authorization code. Runs in its own thread.
This method can be used to handle the auth URL in the case that the system doesn't support theopenBrowser()
method.- Parameters:
consumer
- consumer- Returns:
- builder
- Since:
- 2.0.0
- See Also:
-
build
Returns the built authenticator.- Returns:
- authenticator
- Throws:
IllegalArgumentException
- if port was invalid, or client id or redirect URI was malformedBindException
- if port was blockedNullPointerException
- if server was closed before the client could be authorizedIOException
- Since:
- 1.1.0
- See Also:
-
toString
-