robbert229 / jwt

This is an implementation of JWT in golang!
MIT License
105 stars 27 forks source link

JWT uses base64 URL encoding, not std encoding #10

Closed tartale closed 7 years ago

tartale commented 7 years ago

I ran into the following error decoding a JWT on my system:

unable to decode base64 payload: illegal base64 data at input byte 264

Looks like it's related to the base64 decode function being used: https://github.com/robbert229/jwt/blob/master/algorithms.go#L94

If I switch the line to: payload, err := base64.RawURLEncoding.DecodeString(b64Payload)

then it works! I suspect all of the encoding/decoding needs to use this. Here's the RFC, for reference.