pub async fn callback<T: DeserializeOwned + Send, U: OAuth2UserTrait<T> + ModelTrait, V: OAuth2SessionsTrait<U>, W: DatabasePool + Clone + Debug + Sync + Send + 'static>(
ctx: AppContext,
session: Session<W>,
params: AuthParams,
jar: OAuth2PrivateCookieJar,
client: &mut MutexGuard<'_, dyn GrantTrait>,
) -> Result<impl IntoResponse>
Expand description
Helper function to exchange the code for a token and then get the user profile then upsert the user and the session and set the token in a short live cookie
Lastly, it will redirect the user to the protected URL
§Generics
T
- The user profile, should implementDeserializeOwned
andSend
U
- The user model, should implementOAuth2UserTrait
andModelTrait
V
- The session model, should implementOAuth2SessionsTrait
andModelTrait
W
- The database pool
§Arguments
ctx
- The application contextsession
- The axum sessionparams
- The query parametersjar
- The oauth2 private cookie jarclient
- TheAuthorizationCodeGrant
client
§Returns
Result<impl IntoResponse>
- The response with the short live cookie and the redirect to the protected URL
§Errors
loco_rs::errors::Error