Class DeviceAuthorizationClient
java.lang.Object
com.irurueta.authserver.serviceclient.device.DeviceAuthorizationClient
Calls the standard device flow endpoints of the authorization server. They belong to Spring Authorization
Server, so there is no contract of ours to generate a client from.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final recordError response of the token endpoint (RFC 6749 section 5.2). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringError code meaning the user has not decided yet.static final StringPath of the device authorization endpoint.static final StringGrant type of the token request (RFC 8628 section 3.4).private static final StringThe invalid response.private final DeviceFlowPropertiesThe properties.private final org.springframework.web.client.RestClientThe rest client.static final StringError code meaning the client polls too fast.static final StringPath of the token endpoint. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPolls the token endpoint once.Asks the server for a device code and a user code.private PollOutcomeMaps an error response of the token endpoint to a poll outcome.
-
Field Details
-
DEVICE_AUTHORIZATION_PATH
Path of the device authorization endpoint.- See Also:
-
TOKEN_PATH
Path of the token endpoint.- See Also:
-
DEVICE_CODE_GRANT
Grant type of the token request (RFC 8628 section 3.4).- See Also:
-
AUTHORIZATION_PENDING
Error code meaning the user has not decided yet.- See Also:
-
SLOW_DOWN
Error code meaning the client polls too fast.- See Also:
-
INVALID_RESPONSE
The invalid response.- See Also:
-
restClient
private final org.springframework.web.client.RestClient restClientThe rest client. -
properties
The properties.
-
-
Constructor Details
-
DeviceAuthorizationClient
public DeviceAuthorizationClient()
-
-
Method Details
-
requestDeviceAuthorization
Asks the server for a device code and a user code.- Returns:
- the authorization the user has to approve.
- Throws:
DeviceFlowException- if the request fails or the answer is unusable.
-
pollToken
Polls the token endpoint once.- Parameters:
deviceCode- the device code returned byrequestDeviceAuthorization().- Returns:
- what the server answered.
- Throws:
DeviceFlowException- if the server cannot be reached or the answer is not an OAuth response.
-
toOutcome
Maps an error response of the token endpoint to a poll outcome.- Parameters:
error- the error response; may benull.- Returns:
- the outcome.
-