Examples of how to get ID_token from Google OpenID Connect
Try this:
type jwtClaims struct {
Iss string `json:"iss"`
Azp string `json:"azp"`
Aud string `json:"aud"`
Sub string `json:"sub"`
Hd string `json:"hd"`
Email string `json:"email"`
EmailVerified bool `json:"email_verified"`
AtHash string `json:"at_hash"`
Nonce string `json:"nonce"`
Iat int `json:"iat"`
Exp int `json:"exp"`
}
func extractJwtClaims(token string) (*jwtClaims, error) {
tokenStruct := &jwtClaims{}
jwtParts := strings.Split(token, ".")
out, _ := base64.RawURLEncoding.DecodeString(jwtParts[1])
err := json.Unmarshal(out, &tokenStruct)
if err != nil {
return nil, err
}
return tokenStruct, nil
}
func main() {
token, _ := extractJwtClaims(tok.id_token)
}
I get the "id_token", just like the code below.
import "golang.org/x/oauth2"
func GetIDTokenWithTokenInfo(tokenInfo *oauth2.Token) string {
rawIDToken := tokenInfo.Extra("id_token").(string)
return rawIDToken
}