async fn refresh_token(settings: Arc<Settings>, headers: &HeaderMap) -> Option<Token> {
    let refresh_token = match headers
        .typed_get::<headers::Cookie>()
        .and_then(|cookie| cookie.get(&settings.refresh_cookie).map(str::to_string))
    {
        Some(token) => token,
        None => {
            info!("No refresh token present");
            return None;
        }
    };
    info!("Trying token refresh");
    match settings
        .openid_client
        .refresh_token(
            openid::Bearer {
                access_token: "".to_string(),
                refresh_token: Some(refresh_token),
                expires: None,
                id_token: None,
                scope: None,
            },
            None,
        )
        .await
    {
        Ok(bearer) => Some(Token {
            raw: bearer.id_token.unwrap_or(bearer.access_token),
            expires: bearer.expires,
            raw_refresh: bearer.refresh_token,
        }),
        Err(err) => {
            error!("Token refresh failed: {}", err);
            None
        }
    }
}
// Try to get a new id token with the refresh token.
Try to get a new id token with the refresh token.
Try to get a new id token with the refresh token .
async fn refresh_token(settings: Arc<Settings>, headers: &HeaderMap) -> Option<Token> {
    let refresh_token = match headers
        .typed_get::<headers::Cookie>()
        .and_then(|cookie| cookie.get(&settings.refresh_cookie).map(str::to_string))
    {
        Some(token) => token,
        None => {
            info!("No refresh token present");
            return None;
        }
    };
    info!("Trying token refresh");
    match settings
        .openid_client
        .refresh_token(
            openid::Bearer {
                access_token: "".to_string(),
                refresh_token: Some(refresh_token),
                expires: None,
                id_token: None,
                scope: None,
            },
            None,
        )
        .await
    {
        Ok(bearer) => Some(Token {
            raw: bearer.id_token.unwrap_or(bearer.access_token),
            expires: bearer.expires,
            raw_refresh: bearer.refresh_token,
        }),
        Err(err) => {
            error!("Token refresh failed: {}", err);
            None
        }
    }
}
async fn refresh_token ( settings : Arc < Settings > , headers : & HeaderMap ) -> Option < Token > { let refresh_token = match headers . typed_get :: < headers :: Cookie > ( ) . and_then ( | cookie | cookie . get ( & settings . refresh_cookie ) . map ( str :: to_string ) ) { Some ( token ) => token , None => { info ! ( " " ) ; return None ; } } ; info ! ( " " ) ; match settings . openid_client . refresh_token ( openid :: Bearer { access_token : " " . to_string ( ) , refresh_token : Some ( refresh_token ) , expires : None , id_token : None , scope : None , } , None , ) . await { Ok ( bearer ) => Some ( Token { raw : bearer . id_token . unwrap_or ( bearer . access_token ) , expires : bearer . expires , raw_refresh : bearer . refresh_token , } ) , Err ( err ) => { error ! ( " " err ) ; None } } }
Try to get a new id token with the refresh token.
Try to get a new id token with the refresh token .
settings
Arc<Settings>
headers
&HeaderMap
settings
Arc<Settings>
headers
&HeaderMap