Class DiscordOAuth2Server.Builder

  • Enclosing class:
    DiscordOAuth2Server

    public static class DiscordOAuth2Server.Builder
    extends Object
    Builder suited for creating an OAuth2Server.
    • 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
      • 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
      • 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 the OAuth2Server
        Returns:
        an OAuth2Server with the configured parameters.