jwt icon indicating copy to clipboard operation
jwt copied to clipboard

Bug in logic for decoding anything other than MapClaims

Open lggomez opened this issue 4 years ago • 2 comments

Migrated from https://github.com/dgrijalva/jwt-go/issues/458

smcallis commented on Mar 17

jwt-go/parser.go

Line 131 in dc14462 err = dec.Decode(&claims)

Since this function takes claims as Claims, if you pass anything other than MapClaims{}, you'll get an unmarshalling error: Error verifying token: json: cannot unmarshal object into Go value of type jwt.Claims

lggomez avatar Aug 03 '21 12:08 lggomez

niclasgeiger commented on May 21

ah, if you use &MapClaims{} instead of MapClaims{} it will work. See https://stackoverflow.com/questions/50564341/pointer-to-an-interface-vs-interface-holding-a-pointer-when-unmarshaling-json for more explanations

lggomez avatar Aug 03 '21 12:08 lggomez

when fix it?

JK-97 avatar Jul 18 '23 01:07 JK-97