Class DeviceAuthorizationRequest

  • All Implemented Interfaces:
    Message, Request

    @Immutable
    public class DeviceAuthorizationRequest
    extends AbstractOptionallyIdentifiedRequest
    Device authorisation request. Used to start the authorization 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 (draft-ietf-oauth-device-flow-15)
    • Constructor Detail

      • DeviceAuthorizationRequest

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

        public DeviceAuthorizationRequest​(URI uri,
                                          ClientID clientID,
                                          Scope scope)
        Creates a new device authorization request.
        Parameters:
        uri - The URI of the device authorization endpoint. May be null if the toHTTPRequest() method will not 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 uri,
                                          ClientID clientID,
                                          Scope scope,
                                          Map<String,​List<String>> customParams)
        Creates a new 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.
        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 Detail

      • getRegisteredParameterNames

        public static Set<StringgetRegisteredParameterNames()
        Returns the registered (standard) OAuth 2.0 device authorization request parameter names.
        Returns:
        The registered OAuth 2.0 device authorization request parameter names, as a unmodifiable set.
      • getScope

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

        public Map<String,​List<String>> getCustomParameters()
        Returns the additional custom parameters.
        Returns:
        The additional custom parameters as a unmodifiable map, empty map if none.
      • getCustomParameter

        public List<StringgetCustomParameter​(String name)
        Returns the specified custom parameter.
        Parameters:
        name - The parameter name. Must not be null.
        Returns:
        The parameter value(s), null if not specified.
      • parse

        public static DeviceAuthorizationRequest parse​(HTTPRequest httpRequest)
                                                throws ParseException
        Parses an 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.