Package discord4j.oauth2
Class DiscordOAuth2Server.Builder
java.lang.Object
discord4j.oauth2.DiscordOAuth2Server.Builder
- Enclosing class:
- DiscordOAuth2Server
Builder suited for creating an
OAuth2Server.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddRedirectUri(String redirectUri) Add the given redirect URI to the list of URIs this server should receive requests from; must be a URI defined in the OAuth2 section of the Discord developer portal of the Discord application associated with the resulting server.Add the given scope to the list of scopes that the exchanged access token will grant.build()Create theOAuth2ServerclientId(long clientId) Set the client ID of the Discord application associated with the resulting server.clientSecret(String clientSecret) Set the client secret of the Discord application associated with the resulting server.httpServer(HttpServer httpServer) Set theHttpServerthis OAuth2 server should use to handle HTTP requests.Override the route path this server uses to register the authorization handler.objectMapper(ObjectMapper objectMapper) Set theObjectMapperthis server should use to encode JSON responses.onAuthSuccess(DiscordOAuth2SuccessHandler successHandler) Add a handler to be called once authorization succeeds allowing aDiscordOAuth2Clientto be saved.responseHandler(DiscordOAuth2ResponseHandler responseHandler) Add a handler called once an OAuth2 login completes, allowing to transform the response sent by the server.route(Consumer<HttpServerRoutes> routesCustomizer) Set the route customization for the reactor-netty HTTP server.
-
Constructor Details
-
Builder
-
-
Method Details
-
clientId
Set the client ID of the Discord application associated with the resulting server.- Parameters:
clientId- the client ID obtained from the Discord developer portal- Returns:
- this builder
-
clientSecret
Set the client secret of the Discord application associated with the resulting server.- Parameters:
clientSecret- the client secret obtained from the Discord developer portal- Returns:
- this builder
-
addRedirectUri
Add the given redirect URI to the list of URIs this server should receive requests from; must be a URI defined in the OAuth2 section of the Discord developer portal of the Discord application associated with the resulting server.- Parameters:
redirectUri- the redirect URI- Returns:
- this builder
-
httpServer
Set theHttpServerthis OAuth2 server should use to handle HTTP requests.- Parameters:
httpServer- the HTTP server- Returns:
- this builder
-
objectMapper
Set theObjectMapperthis server should use to encode JSON responses.- Parameters:
objectMapper- the object mapper- Returns:
- this builder
-
addScope
Add the given scope to the list of scopes that the exchanged access token will grant.- Parameters:
scope- the scope to grant- Returns:
- this builder
-
onAuthSuccess
Add a handler to be called once authorization succeeds allowing aDiscordOAuth2Clientto be saved.- Parameters:
successHandler- a handler invoked every time a user authorization succeeds- Returns:
- this builder
-
responseHandler
Add a handler called once an OAuth2 login completes, allowing to transform the response sent by the server.- Parameters:
responseHandler- a handler invoked every time a user authorization succeeds- Returns:
- this builder
-
loginPath
Override the route path this server uses to register the authorization handler. By default, it's the root path ('/')- Parameters:
path- the new login path to use- Returns:
- the builder
-
route
Set the route customization for the reactor-netty HTTP server. By default, this server only registers a path to process incoming authorization requests.- Parameters:
routesCustomizer- a lambda to include additional HTTP routes to the server- Returns:
- this builder
-
build
Create theOAuth2Server- Returns:
- an
OAuth2Serverwith the configured parameters.
-