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
-
@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)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DeviceAuthorizationRequest.Builder
Builder for constructing authorisation requests.
-
Constructor Summary
Constructors Constructor Description DeviceAuthorizationRequest(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 uri, ClientID clientID)
Creates a new minimal device authorization request.DeviceAuthorizationRequest(URI uri, ClientID clientID, Scope scope)
Creates a new device authorization request.DeviceAuthorizationRequest(URI uri, ClientID clientID, Scope scope, Map<String,List<String>> customParams)
Creates a new device authorization request with extension and custom parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getCustomParameter(String name)
Returns the specified custom parameter.Map<String,List<String>>
getCustomParameters()
Returns the additional custom parameters.static Set<String>
getRegisteredParameterNames()
Returns the registered (standard) OAuth 2.0 device authorization request parameter names.Scope
getScope()
Gets the scope.static DeviceAuthorizationRequest
parse(HTTPRequest httpRequest)
Parses an device authorization request from the specified HTTP request.HTTPRequest
toHTTPRequest()
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 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 benull
if thetoHTTPRequest()
method will not be used.clientID
- The client identifier. Corresponds to theclient_id
parameter. Must not benull
.
-
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 benull
if thetoHTTPRequest()
method will not 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 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 benull
if thetoHTTPRequest()
method will not 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 Detail
-
getRegisteredParameterNames
public static Set<String> 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 a unmodifiable set.
-
getScope
public Scope getScope()
Gets the scope. Corresponds to the optionalscope
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<String> getCustomParameter(String name)
Returns the specified custom parameter.- Parameters:
name
- The parameter name. Must not benull
.- Returns:
- The parameter value(s),
null
if not specified.
-
toHTTPRequest
public HTTPRequest toHTTPRequest()
Returns the matching HTTP request.- Returns:
- The HTTP request.
-
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 benull
.- Returns:
- The device authorization request.
- Throws:
ParseException
- If the HTTP request couldn't be parsed to an device authorization request.
-
-