Class DeviceAuthorizationSuccessResponse

java.lang.Object
com.nimbusds.oauth2.sdk.device.DeviceAuthorizationResponse
com.nimbusds.oauth2.sdk.device.DeviceAuthorizationSuccessResponse
All Implemented Interfaces:
Message, Response, 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)
  • Constructor Details

    • 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 Details

    • getRegisteredParameterNames

      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

      Returns the device verification code.
      Returns:
      The device verification code.
    • getUserCode

      Returns the end-user verification code.
      Returns:
      The end-user verification code.
    • getVerificationURI

      Returns the end-user verification URI on the authorization server.
      Returns:
      The end-user verification URI on the authorization server.
    • getVerificationUri

      Deprecated.
      See Also:
    • 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.
    • getVerificationUriComplete

      Deprecated.
      See Also:
    • 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

      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.
    • toHTTPResponse

      Description copied from interface: Response
      Returns the matching HTTP response.
      Specified by:
      toHTTPResponse in interface Response
      Returns:
      The HTTP response.
    • 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

      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.