Class DeviceAuthorizationRequest

All Implemented Interfaces:
Message, Request

Device authorisation request. Used to start the authorisation flow for browserless and input constraint devices. Supports custom request parameters.

Extending classes may define additional request parameters as well as enforce tighter requirements on the base parameters.

Example HTTP request:

 POST /device_authorization HTTP/1.1
 Host: server.example.com
 Content-Type: application/x-www-form-urlencoded

 client_id=459691054427
 

Related specifications:

  • OAuth 2.0 Device Authorization Grant (RFC 8628)
  • Constructor Details

    • DeviceAuthorizationRequest

      public DeviceAuthorizationRequest(URI endpoint, ClientID clientID)
      Creates a new minimal device authorization request.
      Parameters:
      endpoint - The URI of the device authorization endpoint. May be null if the toHTTPRequest() method is not going to be used.
      clientID - The client identifier. Corresponds to the client_id parameter. Must not be null.
    • DeviceAuthorizationRequest

      public DeviceAuthorizationRequest(URI endpoint, ClientID clientID, Scope scope)
      Creates a new device authorization request.
      Parameters:
      endpoint - The URI of the device authorization endpoint. May be null if the toHTTPRequest() method is not going to be used.
      clientID - The client identifier. Corresponds to the client_id parameter. Must not be null.
      scope - The request scope. Corresponds to the optional scope parameter. null if not specified.
    • DeviceAuthorizationRequest

      public DeviceAuthorizationRequest(URI endpoint, ClientID clientID, Scope scope, Map<String,List<String>> customParams)
      Creates a new device authorization request with extension and custom parameters.
      Parameters:
      endpoint - The URI of the device authorization endpoint. May be null if the toHTTPRequest() method is not going to be used.
      clientID - The client identifier. Corresponds to the client_id parameter. Must not be null.
      scope - The request scope. Corresponds to the optional scope parameter. null if not specified.
      customParams - Custom parameters, empty map or null if none.
    • DeviceAuthorizationRequest

      public DeviceAuthorizationRequest(URI uri, ClientAuthentication clientAuth, Scope scope, Map<String,List<String>> customParams)
      Creates a new authenticated device authorization request with extension and custom parameters.
      Parameters:
      uri - The URI of the device authorization endpoint. May be null if the toHTTPRequest() method will not be used.
      clientAuth - The client authentication. Must not be null.
      scope - The request scope. Corresponds to the optional scope parameter. null if not specified.
      customParams - Custom parameters, empty map or null if none.
  • Method Details

    • getRegisteredParameterNames

      Returns the registered (standard) OAuth 2.0 device authorization request parameter names.
      Returns:
      The registered OAuth 2.0 device authorization request parameter names, as an unmodifiable set.
    • getScope

      public Scope getScope()
      Gets the scope. Corresponds to the optional scope parameter.
      Returns:
      The scope, null if not specified.
    • getCustomParameters

      Returns the additional custom parameters.
      Returns:
      The additional custom parameters as an unmodifiable map, empty map if none.
    • getCustomParameter

      Returns the specified custom parameter.
      Parameters:
      name - The parameter name. Must not be null.
      Returns:
      The parameter value(s), null if not specified.
    • toHTTPRequest

      Returns the matching HTTP request.
      Returns:
      The HTTP request.
    • parse

      public static DeviceAuthorizationRequest parse(HTTPRequest httpRequest) throws ParseException
      Parses a device authorization request from the specified HTTP request.

      Example HTTP request (GET):

       POST /device_authorization HTTP/1.1
       Host: server.example.com
       Content-Type: application/x-www-form-urlencoded
      
       client_id=459691054427
       
      Parameters:
      httpRequest - The HTTP request. Must not be null.
      Returns:
      The device authorization request.
      Throws:
      ParseException - If the HTTP request couldn't be parsed to an device authorization request.