Class DeviceAuthorizationClient

java.lang.Object
com.irurueta.authserver.serviceclient.device.DeviceAuthorizationClient

@Component @Profile("device-flow") public class DeviceAuthorizationClient extends Object
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.
  • Field Details

    • DEVICE_AUTHORIZATION_PATH

      public static final String DEVICE_AUTHORIZATION_PATH
      Path of the device authorization endpoint.
      See Also:
    • TOKEN_PATH

      public static final String TOKEN_PATH
      Path of the token endpoint.
      See Also:
    • DEVICE_CODE_GRANT

      public static final String DEVICE_CODE_GRANT
      Grant type of the token request (RFC 8628 section 3.4).
      See Also:
    • AUTHORIZATION_PENDING

      public static final String AUTHORIZATION_PENDING
      Error code meaning the user has not decided yet.
      See Also:
    • SLOW_DOWN

      public static final String SLOW_DOWN
      Error code meaning the client polls too fast.
      See Also:
    • INVALID_RESPONSE

      private static final String INVALID_RESPONSE
      The invalid response.
      See Also:
    • restClient

      private final org.springframework.web.client.RestClient restClient
      The rest client.
    • properties

      private final DeviceFlowProperties properties
      The properties.
  • Constructor Details

    • DeviceAuthorizationClient

      public DeviceAuthorizationClient()
  • Method Details

    • requestDeviceAuthorization

      public DeviceAuthorization 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

      public PollOutcome pollToken(String deviceCode)
      Polls the token endpoint once.
      Parameters:
      deviceCode - the device code returned by requestDeviceAuthorization().
      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 be null.
      Returns:
      the outcome.