jws: use base64.RawURLEncoding

The Raw (unpadded) version of URL encoding was introduced in Go 1.5.
Since we no longer need to support Go 1.4 (and indeed, Go 1.4 won't work
because of our dependency on golang.org/x/net/context), we can simplify
the base64 encoding/decoding to use this directly.

Fixes golang/oauth2#190.

Change-Id: Ic2676edf5fe5b4d1680409fd9c02bd1c287ca39f
Reviewed-on: https://go-review.googlesource.com/25000
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Dave Day
2016-07-18 10:34:09 +10:00
parent 4470bd844e
commit a870243201
2 changed files with 7 additions and 28 deletions

View File

@@ -76,8 +76,7 @@ func TestJWTAccessTokenSourceFromJSON(t *testing.T) {
// Finally, check the header private key.
parts := strings.Split(tok.AccessToken, ".")
parts[0] += strings.Repeat("=", len(parts[0])%4) // Add padding.
hdrJSON, err := base64.URLEncoding.DecodeString(parts[0])
hdrJSON, err := base64.RawURLEncoding.DecodeString(parts[0])
if err != nil {
t.Fatalf("base64 DecodeString: %v\nString: %q", err, parts[0])
}