Package com.nimbusds.oauth2.sdk.device
Class DeviceAuthorizationSuccessResponse
java.lang.Object
com.nimbusds.oauth2.sdk.device.DeviceAuthorizationResponse
com.nimbusds.oauth2.sdk.device.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)
-
Constructor Summary
ConstructorsConstructorDescriptionDeviceAuthorizationSuccessResponse
(DeviceCode deviceCode, UserCode userCode, URI verificationURI, long lifetime) Creates a new device authorization success response.DeviceAuthorizationSuccessResponse
(DeviceCode deviceCode, UserCode userCode, URI verificationURI, URI verificationURIComplete, long lifetime, long interval, Map<String, Object> customParams) Creates a new device authorization success response. -
Method Summary
Modifier and TypeMethodDescriptionReturns the custom parameters.Returns the device verification code.long
Returns the minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoint.long
Returns the lifetime in seconds of the "device_code" and "user_code".Returns the registered (standard) OAuth 2.0 device authorization response parameter names.Returns the end-user verification code.Deprecated.Returns the end-user verification URI on the authorization server.Deprecated.Returns the end-user verification URI that includes the user_code.boolean
Checks if the response indicates success.parse
(HTTPResponse httpResponse) Parses an device authorization response from the specified HTTP response.parse
(net.minidev.json.JSONObject jsonObject) Parses an device authorization response from the specified JSON object.Returns the matching HTTP response.net.minidev.json.JSONObject
Returns a JSON object representation of this device authorization response.Methods inherited from class com.nimbusds.oauth2.sdk.device.DeviceAuthorizationResponse
toErrorResponse, toSuccessResponse
-
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 benull
.userCode
- The user verification code. Must not benull
.verificationURI
- The end-user verification URI on the authorization server. Must not benull
.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 benull
.userCode
- The user verification code. Must not benull
.verificationURI
- The end-user verification URI on the authorization server. Must not benull
.verificationURIComplete
- The end-user verification URI on the authorization server that includes the user_code. Can benull
.lifetime
- The lifetime in seconds of the "device_code" and "user_code". Must be greater than0
.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
Description copied from interface:Response
Checks if the response indicates success.- Specified by:
indicatesSuccess
in interfaceResponse
- Returns:
true
if the response indicates success, elsefalse
.
-
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
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
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
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 interfaceResponse
- 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 benull
.- 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 benull
.- Returns:
- The device authorization response.
- Throws:
ParseException
- If the HTTP response couldn't be parsed to a device authorization response.
-