pub struct OAuth2PasswordRequestForm {
pub grant_type: Option<String>,
pub username: String,
pub password: String,
pub scope: String,
pub client_id: Option<String>,
pub client_secret: Option<String>,
}Expand description
OAuth2 password request form data.
Extracts the standard OAuth2 password grant fields from a
application/x-www-form-urlencoded request body, matching FastAPI’s
OAuth2PasswordRequestForm.
§Fields
grant_type: Optional, should be"password"per spec (not enforced here; useOAuth2PasswordRequestFormStrictfor strict validation).username: Required.password: Required.scope: Space-separated scopes (empty string if not provided).client_id: Optional.client_secret: Optional.
§Computed
scopes(): Returns thescopestring split into aVec<String>.
§Example
ⓘ
use fastapi_core::OAuth2PasswordRequestForm;
async fn login(form: OAuth2PasswordRequestForm) -> Response {
let username = &form.username;
let password = &form.password;
let scopes = form.scopes();
// ... authenticate user ...
}Fields§
§grant_type: Option<String>The grant type. Should be "password" per the OAuth2 spec.
username: StringThe username (required).
password: StringThe password (required).
scope: StringSpace-separated scopes. Defaults to empty string.
client_id: Option<String>Optional client ID.
client_secret: Option<String>Optional client secret.
Implementations§
Trait Implementations§
Source§impl Clone for OAuth2PasswordRequestForm
impl Clone for OAuth2PasswordRequestForm
Source§fn clone(&self) -> OAuth2PasswordRequestForm
fn clone(&self) -> OAuth2PasswordRequestForm
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OAuth2PasswordRequestForm
impl Debug for OAuth2PasswordRequestForm
Source§impl FromRequest for OAuth2PasswordRequestForm
impl FromRequest for OAuth2PasswordRequestForm
Source§type Error = OAuth2PasswordFormError
type Error = OAuth2PasswordFormError
Error type when extraction fails.
Source§async fn from_request(
ctx: &RequestContext,
req: &mut Request,
) -> Result<Self, Self::Error>
async fn from_request( ctx: &RequestContext, req: &mut Request, ) -> Result<Self, Self::Error>
Extract a value from the request. Read more
Auto Trait Implementations§
impl Freeze for OAuth2PasswordRequestForm
impl RefUnwindSafe for OAuth2PasswordRequestForm
impl Send for OAuth2PasswordRequestForm
impl Sync for OAuth2PasswordRequestForm
impl Unpin for OAuth2PasswordRequestForm
impl UnwindSafe for OAuth2PasswordRequestForm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).