type AsyncAuthenticator[T] = Credentials ⇒ Future[Option[T]]
def authenticateOAuth2Async[T](realm: String, authenticator: AsyncAuthenticator[T]): AuthenticationDirective[T]
Wraps the inner route with OAuth Bearer Token authentication support using a given
This directive does not implement the complete OAuth2 protocol, but instead enables implementing it, by extracting the needed token from the HTTP headers.
Given a function returning
Some[T]a non empty
Optional<T> upon successful authentication and
Optional<T> otherwise, respectively applies the inner route or rejects the request with a AuthenticationFailedRejectionAuthenticationFailedRejection rejection, which by default is mapped to an
401 Unauthorized response.
See also authenticateOAuth2 if the authorization operation is rather quick, and does not have to execute asynchronously.
See Credentials and password timing attacks for details about verifying the secret.
For more information on how OAuth2 works see RFC 6750.
Usage in code is exactly the same as authenticateBasicAsync, with the difference that one must validate the token as OAuth2 dictates (which is currently not part of Akka HTTP itself).