callback

Function callback 

Source
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 implement DeserializeOwned and Send
  • U - The user model, should implement OAuth2UserTrait and ModelTrait
  • V - The session model, should implement OAuth2SessionsTrait and ModelTrait
  • W - The database pool

§Arguments

  • ctx - The application context
  • session - The axum session
  • params - The query parameters
  • jar - The oauth2 private cookie jar
  • client - The AuthorizationCodeGrant client

§Returns

  • Result<impl IntoResponse> - The response with the short live cookie and the redirect to the protected URL

§Errors

  • loco_rs::errors::Error