Package discord4j.oauth2
Class DiscordOAuth2Server.Builder
- java.lang.Object
-
- discord4j.oauth2.DiscordOAuth2Server.Builder
-
- Enclosing class:
- DiscordOAuth2Server
public static class DiscordOAuth2Server.Builder extends Object
Builder suited for creating anOAuth2Server
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder(RestClient restClient)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DiscordOAuth2Server.Builder
addRedirectUri(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.DiscordOAuth2Server.Builder
addScope(Scope scope)
Add the given scope to the list of scopes that the exchanged access token will grant.DiscordOAuth2Server
build()
Create theOAuth2Server
DiscordOAuth2Server.Builder
clientId(long clientId)
Set the client ID of the Discord application associated with the resulting server.DiscordOAuth2Server.Builder
clientSecret(String clientSecret)
Set the client secret of the Discord application associated with the resulting server.DiscordOAuth2Server.Builder
httpServer(HttpServer httpServer)
Set theHttpServer
this OAuth2 server should use to handle HTTP requests.DiscordOAuth2Server.Builder
loginPath(String path)
Override the route path this server uses to register the authorization handler.DiscordOAuth2Server.Builder
objectMapper(ObjectMapper objectMapper)
Set theObjectMapper
this server should use to encode JSON responses.DiscordOAuth2Server.Builder
onAuthSuccess(DiscordOAuth2SuccessHandler successHandler)
Add a handler to be called once authorization succeeds allowing aDiscordOAuth2Client
to be saved.DiscordOAuth2Server.Builder
responseHandler(DiscordOAuth2ResponseHandler responseHandler)
Add a handler called once an OAuth2 login completes, allowing to transform the response sent by the server.DiscordOAuth2Server.Builder
route(Consumer<HttpServerRoutes> routesCustomizer)
Set the route customization for the reactor-netty HTTP server.
-
-
-
Constructor Detail
-
Builder
protected Builder(RestClient restClient)
-
-
Method Detail
-
clientId
public DiscordOAuth2Server.Builder clientId(long 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
public DiscordOAuth2Server.Builder clientSecret(String 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
public DiscordOAuth2Server.Builder addRedirectUri(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.- Parameters:
redirectUri
- the redirect URI- Returns:
- this builder
-
httpServer
public DiscordOAuth2Server.Builder httpServer(HttpServer httpServer)
Set theHttpServer
this OAuth2 server should use to handle HTTP requests.- Parameters:
httpServer
- the HTTP server- Returns:
- this builder
-
objectMapper
public DiscordOAuth2Server.Builder objectMapper(ObjectMapper objectMapper)
Set theObjectMapper
this server should use to encode JSON responses.- Parameters:
objectMapper
- the object mapper- Returns:
- this builder
-
addScope
public DiscordOAuth2Server.Builder addScope(Scope scope)
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
public DiscordOAuth2Server.Builder onAuthSuccess(DiscordOAuth2SuccessHandler successHandler)
Add a handler to be called once authorization succeeds allowing aDiscordOAuth2Client
to be saved.- Parameters:
successHandler
- a handler invoked every time a user authorization succeeds- Returns:
- this builder
-
responseHandler
public DiscordOAuth2Server.Builder responseHandler(DiscordOAuth2ResponseHandler 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
public DiscordOAuth2Server.Builder loginPath(String path)
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
public DiscordOAuth2Server.Builder route(Consumer<HttpServerRoutes> routesCustomizer)
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
public DiscordOAuth2Server build()
Create theOAuth2Server
- Returns:
- an
OAuth2Server
with the configured parameters.
-
-