How to extract and verify token sent from frontend

前端 未结 4 726
深忆病人
深忆病人 2021-01-04 00:36

I am using "github.com/dgrijalva/jwt-go", and able to send a token to my frontend, and what I would like to know how I could retrieve the token sent from the front

4条回答
  •  伪装坚强ぢ
    2021-01-04 01:12

    Credit: https://github.com/harlow/authtoken/blob/master/authtoken.go

    const BEARER_SCHEMA = "Bearer "
    authHeader := req.Header.Get("Authorization")
    token := authHeader[len(BEARER_SCHEMA):]
    

提交回复
热议问题