Created
August 14, 2017 13:13
-
-
Save jeffotoni/c457a7682202dbf822f5cc4496b1d3e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if token, err := request.ParseFromRequest(r, request.OAuth2Extractor, keyLookupFunc2); err == nil { | |
| claims := token.Claims.(jwt.MapClaims) | |
| fmt.Printf("Token for user %v expires %v", claims["user"], claims["exp"]) | |
| } else if err != nil { | |
| fmt.Println("Error: ", err) | |
| switch err.(type) { | |
| case *jwt.ValidationError: | |
| vErr := err.(*jwt.ValidationError) | |
| switch vErr.Errors { | |
| case jwt.ValidationErrorExpired: | |
| fmt.Fprintln(w, "Your token has expired!") | |
| return | |
| case jwt.ValidationErrorSignatureInvalid: | |
| fmt.Fprintln(w, "Token signature does not match!") | |
| return | |
| default: | |
| fmt.Fprintln(w, "Your token is invalid!") | |
| return | |
| } | |
| default: | |
| fmt.Fprintln(w, "Your token is invalid!") | |
| return | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment