Skip to content

Commit 85b964a

Browse files
committed
fix: use URL-safe base64 encoding
Prior to this commit, this used standard encoding, which worked up until relatively recently. Now, unfortunately, using standard encoding appears to be unsupported: ``` error: unexpected status code from GitHub API (401): { "message": "Bad credentials", "documentation_url": "https://docs.github.com/rest", "status": "401" } ``` This is, in a sense, not surprising because JWTs are typically base64 URL-safe encoded. It's surprising that this worked before, however.
1 parent da7a0bc commit 85b964a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

internal/jwt.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (s *payloadSigner) appendPayload(payload any) (string, error) {
5050
return "", err
5151
}
5252

53-
return jwtHeader + "." + base64.StdEncoding.EncodeToString(jsonPayload), nil
53+
return jwtHeader + "." + base64.RawURLEncoding.EncodeToString(jsonPayload), nil
5454
}
5555

5656
func (s *payloadSigner) appendSignature(hp string) (string, error) {
@@ -62,5 +62,5 @@ func (s *payloadSigner) appendSignature(hp string) (string, error) {
6262
return "", err
6363
}
6464

65-
return hp + "." + base64.StdEncoding.EncodeToString(signature), nil
65+
return hp + "." + base64.RawURLEncoding.EncodeToString(signature), nil
6666
}

0 commit comments

Comments
 (0)