2

In my go backend application I generated a token when my app is initialised.And I want to use this token as a global variable for further authentications.

type Token struct {
    Name         string
    Value        string
    RefreshValue string
    Expires      time.Time
}
AppToken := GetToken()
func main() {
  
   router := mux.NewRouter()
   router.HandleFunc("/employees", GetEmployeesHandler).Methods("GET")
}
func GetEmployeesHandler (w http.ResponseWriter, r *http.Request) {
    w.WriteHeader(http.StatusOK)
    //here i want to pass token, here i validate token and check token is expired
    err := CheckToken(AppToken)
    if err != nil {
       return err
    }
    fmt.Fprintf(w, "API is up and running")
}

My requirement is that whenever the token expires I want to refresh the token I also want to ensure the refresh token should be blocked when there is already a refresh token process that is taking place. Please help me.

1

0

Browse other questions tagged or ask your own question.