pub struct TokenRequest<'a> { /* private fields */ }Expand description
One token request, assembled from an AuthorizedCode and a registration.
Borrowed rather than owned because every member already exists in one of those two values and copying it would create a second copy of a credential to keep alive for no reason.
§Examples
An implementor reads what it needs and encodes it however its transport
requires; the oauth adapter reads all of it:
struct Transport;
impl TokenEndpoint for Transport {
async fn redeem(
&self,
request: TokenRequest<'_>,
) -> Result<IssuedToken, TokenEndpointError> {
let body = format!(
"grant_type=authorization_code&code={}&redirect_uri={}",
request.code(),
request.redirect_uri(),
);
println!("{body}");
.map_err(TokenEndpointError::Refused)
}
}Implementations§
Source§impl<'a> TokenRequest<'a>
impl<'a> TokenRequest<'a>
Sourcepub const fn redirect_uri(&self) -> &'a str
pub const fn redirect_uri(&self) -> &'a str
The redirect URI, exactly as the authorization request carried it.
Sourcepub const fn code_verifier(&self) -> &'a CodeVerifier
pub const fn code_verifier(&self) -> &'a CodeVerifier
The PKCE verifier the code_challenge was derived from.
Sourcepub const fn client_secret(&self) -> Option<&'a ClientSecret>
pub const fn client_secret(&self) -> Option<&'a ClientSecret>
The secret, for a confidential client only.
None for a public client — one registered through a client
identity metadata document, which has nowhere to keep a secret that is
still secret. An adapter must omit the member in that case rather
than sending it empty: an empty client_secret is a value, and RFC 6749
§2.3.1 treats the presence of the member as the statement that the
client is confidential.
Sourcepub const fn auth_method(&self) -> TokenAuthMethod
pub const fn auth_method(&self) -> TokenAuthMethod
How the client authenticates at the token endpoint.
Sourcepub const fn scope(&self) -> Option<&'a str>
pub const fn scope(&self) -> Option<&'a str>
The scope to send with the token request, if any.
The authorization page lets a client that wants a refresh token add
offline_access “to the scope parameter of the authorization and
token requests”, so the token request carries the scope the
authorization request asked for.
Sourcepub const fn resource(&self) -> &'a ResourceParameters
pub const fn resource(&self) -> &'a ResourceParameters
The RFC 8707 resource indicators this grant is bound to.
Repeated as one resource member per indicator, which is the encoding
§2 of that RFC defines.