Class DeviceAuthorizationSuccessResponse

  • All Implemented Interfaces:
    Message, Response, SuccessResponse

    @Immutable
    public class DeviceAuthorizationSuccessResponse
    extends DeviceAuthorizationResponse
    implements SuccessResponse
    A device authorization response from the device authorization endpoint.

    Example HTTP response:

     HTTP/1.1 200 OK
     Content-Type: application/json;charset=UTF-8
     Cache-Control: no-store
     Pragma: no-cache
    
     {
       "device_code"               : "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS",
       "user_code"                 : "WDJB-MJHT",
       "verification_uri"          : "https://example.com/device",
       "verification_uri_complete" : "https://example.com/device?user_code=WDJB-MJHT",
       "expires_in"                : 1800,
       "interval"                  : 5
     }
     

    Related specifications:

    • OAuth 2.0 Device Authorization Grant (RFC 8628), section 3.2.
    • Constructor Detail

      • DeviceAuthorizationSuccessResponse

        public DeviceAuthorizationSuccessResponse​(DeviceCode deviceCode,
                                                  UserCode userCode,
                                                  URI verificationURI,
                                                  long lifetime)
        Creates a new device authorization success response.
        Parameters:
        deviceCode - The device verification code. Must not be null.
        userCode - The user verification code. Must not be null.
        verificationURI - The end-user verification URI on the authorization server. Must not be null.
        lifetime - The lifetime in seconds of the "device_code" and "user_code".
      • DeviceAuthorizationSuccessResponse

        public DeviceAuthorizationSuccessResponse​(DeviceCode deviceCode,
                                                  UserCode userCode,
                                                  URI verificationURI,
                                                  URI verificationURIComplete,
                                                  long lifetime,
                                                  long interval,
                                                  Map<String,​Object> customParams)
        Creates a new device authorization success response.
        Parameters:
        deviceCode - The device verification code. Must not be null.
        userCode - The user verification code. Must not be null.
        verificationURI - The end-user verification URI on the authorization server. Must not be null.
        verificationURIComplete - The end-user verification URI on the authorization server that includes the user_code. Can be null.
        lifetime - The lifetime in seconds of the "device_code" and "user_code". Must be greater than 0.
        interval - The minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoint.
        customParams - Optional custom parameters, null if none.
    • Method Detail

      • getRegisteredParameterNames

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

        public boolean indicatesSuccess()
        Description copied from interface: Response
        Checks if the response indicates success.
        Specified by:
        indicatesSuccess in interface Response
        Returns:
        true if the response indicates success, else false.
      • getDeviceCode

        public DeviceCode getDeviceCode()
        Returns the device verification code.
        Returns:
        The device verification code.
      • getUserCode

        public UserCode getUserCode()
        Returns the end-user verification code.
        Returns:
        The end-user verification code.
      • getVerificationURI

        public URI getVerificationURI()
        Returns the end-user verification URI on the authorization server.
        Returns:
        The end-user verification URI on the authorization server.
      • getVerificationURIComplete

        public URI getVerificationURIComplete()
        Returns the end-user verification URI that includes the user_code.
        Returns:
        The end-user verification URI that includes the user_code, or null if not specified.
      • getLifetime

        public long getLifetime()
        Returns the lifetime in seconds of the "device_code" and "user_code".
        Returns:
        The lifetime in seconds of the "device_code" and "user_code".
      • getInterval

        public long getInterval()
        Returns the minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoint.
        Returns:
        The minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoint.
      • getCustomParameters

        public Map<String,​ObjectgetCustomParameters()
        Returns the custom parameters.
        Returns:
        The custom parameters, as a unmodifiable map, empty map if none.
      • toJSONObject

        public net.minidev.json.JSONObject toJSONObject()
        Returns a JSON object representation of this device authorization response.

        Example JSON object:

         {
           "device_code"               : "GmRhmhcxhwAzkoEqiMEg_DnyEysNkuNhszIySk9eS",
           "user_code"                 : "WDJB-MJHT",
           "verification_uri"          : "https://example.com/device",
           "verification_uri_complete" : "https://example.com/device?user_code=WDJB-MJHT",
           "expires_in"                : 1800,
           "interval"                  : 5
         }
         
        Returns:
        The JSON object.
      • parse

        public static DeviceAuthorizationSuccessResponse parse​(net.minidev.json.JSONObject jsonObject)
                                                        throws ParseException
        Parses an device authorization response from the specified JSON object.
        Parameters:
        jsonObject - The JSON object to parse. Must not be null.
        Returns:
        The device authorization response.
        Throws:
        ParseException - If the JSON object couldn't be parsed to a device authorization response.
      • parse

        public static DeviceAuthorizationSuccessResponse parse​(HTTPResponse httpResponse)
                                                        throws ParseException
        Parses an device authorization response from the specified HTTP response.
        Parameters:
        httpResponse - The HTTP response. Must not be null.
        Returns:
        The device authorization response.
        Throws:
        ParseException - If the HTTP response couldn't be parsed to a device authorization response.