Update token in actix-web 4.3.00

How do I update my token when it expires and pass it to the global reference?

pub async fn kc_init_context() -> InfraResult<Arc<KcContext>> {
    let kc_context = KcContext::new().await?; // connect an create token 

    let utc_now = Utc::now().timestamp();

    if kc_context.claims.exp < utc_now {
        println!("{:?}", "Expired token".to_string());
        /// How create a new token and update global reference ?
        /// kc_context = KcContext::new().await?;

   // println!("{:?}", kc_context.claims);

async fn main() -> std::io::Result<()> {

    let kc_context = kc_init_context().await?;

    HttpServer::new(move || {
            //.wrap_fn(|req, srv| counter_middleware(req, srv))
            .route("/ping", web::get().to(ping))
    .bind(("", 4042))?

maybe using RwLock? I'm not sure how to do that

You should create a struct that is shared across your server, and store your token in such struct.