pub trait TokenEndpoint {
// Required method
fn redeem(
&self,
request: TokenRequest<'_>,
) -> impl Future<Output = Result<IssuedToken, TokenEndpointError>> + Send;
// Provided method
fn refresh(
&self,
request: RefreshRequest<'_>,
) -> impl Future<Output = Result<IssuedToken, TokenEndpointError>> + Send { ... }
}Expand description
Asks an authorization server to trade a code for a token.
One method, and one because redemption is a single act. An adapter does the HTTP; this crate decides what to ask for, and the domain decides what came back.
Not dyn compatible, and that is deliberate. Redemption happens once per
client rather than once per request, so the call site takes impl TokenEndpoint and the monomorphised future costs nothing that a box would
not.
Required Methods§
Sourcefn redeem(
&self,
request: TokenRequest<'_>,
) -> impl Future<Output = Result<IssuedToken, TokenEndpointError>> + Send
fn redeem( &self, request: TokenRequest<'_>, ) -> impl Future<Output = Result<IssuedToken, TokenEndpointError>> + Send
Trade the authorization code for a token.
§Errors
TokenEndpointError::Refused when the server answered RFC 6749 §5.2,
or with a body that was not a usable token. TokenEndpointError::Unavailable
when the server could not be asked or its answer could not be read.
Provided Methods§
Sourcefn refresh(
&self,
request: RefreshRequest<'_>,
) -> impl Future<Output = Result<IssuedToken, TokenEndpointError>> + Send
fn refresh( &self, request: RefreshRequest<'_>, ) -> impl Future<Output = Result<IssuedToken, TokenEndpointError>> + Send
Trade a refresh token for a new access token (RFC 6749 §6).
The default refuses, so an endpoint written before this method existed
keeps compiling and a caller finds out at runtime, as an
TokenEndpointError::Unavailable, that it cannot refresh.
§Errors
As redeem. invalid_grant here means the refresh
token is spent or revoked, and the caller falls back to a full
authorization.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".