Class TokenRequest.Builder

java.lang.Object
com.nimbusds.oauth2.sdk.TokenRequest.Builder
Enclosing class:
TokenRequest

public static class TokenRequest.Builder extends Object
Builder for constructing token requests.
  • Constructor Details

    • Builder

      public Builder(URI endpoint, ClientAuthentication clientAuth, AuthorizationGrant authzGrant)
      Creates a new builder for a token request with client authentication.
      Parameters:
      endpoint - The URI of the token endpoint. May be null if the TokenRequest.toHTTPRequest() method is not going to be used.
      clientAuth - The client authentication. Must not be null.
      authzGrant - The authorisation grant. Must not be null.
    • Builder

      public Builder(URI endpoint, ClientID clientID, AuthorizationGrant authzGrant)
      Creates a new builder for a token request with no (explicit) client authentication. The grant itself may be used to authenticate the client.
      Parameters:
      endpoint - The URI of the token endpoint. May be null if the TokenRequest.toHTTPRequest() method is not going to be used.
      clientID - The client identifier. Must not be null.
      authzGrant - The authorisation grant. Must not be null.
    • Builder

      public Builder(URI endpoint, AuthorizationGrant authzGrant)
      Creates a new builder for a token request with no (explicit) client authentication, the client identifier is inferred from the authorisation grant.
      Parameters:
      endpoint - The URI of the token endpoint. May be null if the TokenRequest.toHTTPRequest() method is not going to be used.
      authzGrant - The authorisation grant. Must not be null.
  • Method Details

    • scope

      Sets the scope. Corresponds to the optional scope parameter.
      Parameters:
      scope - The scope, null if not specified.
      Returns:
      This builder.
    • authorizationDetails

      Sets the Rich Authorisation Request (RAR) details. Corresponds to the optional authorization_details parameter.
      Parameters:
      authorizationDetails - The authorisation details, null if not specified.
      Returns:
      This builder.
    • resource

      public TokenRequest.Builder resource(URI resource)
      Sets the resource server URI. Corresponds to the optional resource parameter.
      Parameters:
      resource - The resource URI, null if not specified.
      Returns:
      This builder.
    • resources

      public TokenRequest.Builder resources(URI... resources)
      Sets the resource server URI(s). Corresponds to the optional resource parameter.
      Parameters:
      resources - The resource URI(s), null if not specified.
      Returns:
      This builder.
    • existingGrant

      Sets the existing refresh token for incremental authorisation of a public client. Corresponds to the optional existing_grant parameter.
      Parameters:
      existingGrant - Existing refresh token for incremental authorisation of a public client, null if not specified.
      Returns:
      This builder.
    • deviceSecret

      Sets the device secret for native SSO. Corresponds to the optional device_secret parameter.
      Parameters:
      deviceSecret - The device secret, null if not specified.
      Returns:
      This builder.
    • customParameter

      Sets a custom parameter.
      Parameters:
      name - The parameter name. Must not be null.
      values - The parameter values, null if not specified.
      Returns:
      This builder.
    • build

      public TokenRequest build()
      Builds a new token request.
      Returns:
      The token request.