Package com.nimbusds.oauth2.sdk.device
Class DeviceAuthorizationRequest
java.lang.Object
com.nimbusds.oauth2.sdk.AbstractRequest
com.nimbusds.oauth2.sdk.AbstractOptionallyAuthenticatedRequest
com.nimbusds.oauth2.sdk.AbstractOptionallyIdentifiedRequest
com.nimbusds.oauth2.sdk.device.DeviceAuthorizationRequest
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)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder for constructing authorisation requests. -
Constructor Summary
ConstructorsConstructorDescriptionDeviceAuthorizationRequest
(URI uri, ClientAuthentication clientAuth, Scope scope, Map<String, List<String>> customParams) Creates a new authenticated device authorization request with extension and custom parameters.DeviceAuthorizationRequest
(URI endpoint, ClientID clientID) Creates a new minimal device authorization request.DeviceAuthorizationRequest
(URI endpoint, ClientID clientID, Scope scope) Creates a new device authorization request.DeviceAuthorizationRequest
(URI endpoint, ClientID clientID, Scope scope, Map<String, List<String>> customParams) Creates a new device authorization request with extension and custom parameters. -
Method Summary
Modifier and TypeMethodDescriptiongetCustomParameter
(String name) Returns the specified custom parameter.Returns the additional custom parameters.Returns the registered (standard) OAuth 2.0 device authorization request parameter names.getScope()
Gets the scope.static DeviceAuthorizationRequest
parse
(HTTPRequest httpRequest) Parses a device authorization request from the specified HTTP request.Returns the matching HTTP request.Methods inherited from class com.nimbusds.oauth2.sdk.AbstractOptionallyIdentifiedRequest
getClientID
Methods inherited from class com.nimbusds.oauth2.sdk.AbstractOptionallyAuthenticatedRequest
getClientAuthentication
Methods inherited from class com.nimbusds.oauth2.sdk.AbstractRequest
getEndpointURI
-
Constructor Details
-
DeviceAuthorizationRequest
Creates a new minimal device authorization request.- Parameters:
endpoint
- The URI of the device authorization endpoint. May benull
if thetoHTTPRequest()
method is not going to be used.clientID
- The client identifier. Corresponds to theclient_id
parameter. Must not benull
.
-
DeviceAuthorizationRequest
Creates a new device authorization request.- Parameters:
endpoint
- The URI of the device authorization endpoint. May benull
if thetoHTTPRequest()
method is not going to be used.clientID
- The client identifier. Corresponds to theclient_id
parameter. Must not benull
.scope
- The request scope. Corresponds to the optionalscope
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 benull
if thetoHTTPRequest()
method is not going to be used.clientID
- The client identifier. Corresponds to theclient_id
parameter. Must not benull
.scope
- The request scope. Corresponds to the optionalscope
parameter.null
if not specified.customParams
- Custom parameters, empty map ornull
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 benull
if thetoHTTPRequest()
method will not be used.clientAuth
- The client authentication. Must not benull
.scope
- The request scope. Corresponds to the optionalscope
parameter.null
if not specified.customParams
- Custom parameters, empty map ornull
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
Gets the scope. Corresponds to the optionalscope
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 benull
.- Returns:
- The parameter value(s),
null
if not specified.
-
toHTTPRequest
Returns the matching HTTP request.- Returns:
- The HTTP request.
-
parse
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 benull
.- Returns:
- The device authorization request.
- Throws:
ParseException
- If the HTTP request couldn't be parsed to an device authorization request.
-