Skip to content

Commit

Permalink
Merge pull request bitly#421 from arnottcr/raw-url-encode
Browse files Browse the repository at this point in the history
raw url encoding
  • Loading branch information
talam authored Nov 20, 2017
2 parents 781bd08 + 8d6e16b commit a7c5d9c
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions providers/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func emailFromIdToken(idToken string) (string, error) {
// id_token is a base64 encode ID token payload
// https://developers.google.com/accounts/docs/OAuth2Login#obtainuserinfo
jwt := strings.Split(idToken, ".")
b, err := jwtDecodeSegment(jwt[1])
b, err := base64.RawURLEncoding.DecodeString(jwt[1])
if err != nil {
return "", err
}
Expand All @@ -89,14 +89,6 @@ func emailFromIdToken(idToken string) (string, error) {
return email.Email, nil
}

func jwtDecodeSegment(seg string) ([]byte, error) {
if l := len(seg) % 4; l > 0 {
seg += strings.Repeat("=", 4-l)
}

return base64.URLEncoding.DecodeString(seg)
}

func (p *GoogleProvider) Redeem(redirectURL, code string) (s *SessionState, err error) {
if code == "" {
err = errors.New("missing code")
Expand Down

0 comments on commit a7c5d9c

Please sign in to comment.