// FetchUser will go to Google and access basic information about the user.
FetchUser will go to Google and access basic information about the user.
// FetchUser will go to Google and access basic information about the user .
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
	sess := session.(*Session)
	user := goth.User{
		AccessToken:  sess.AccessToken,
		Provider:     p.Name(),
		RefreshToken: sess.RefreshToken,
		ExpiresAt:    sess.ExpiresAt,
	}
	if user.AccessToken == "" {
		return user, fmt.Errorf("%s cannot get user information without accessToken", p.providerName)
	}
	claims := jwt.MapClaims{}
	token, _, err := new(jwt.Parser).ParseUnverified(sess.IdToken, claims)
	if err != nil {
		return user, err
	}
	claims = token.Claims.(jwt.MapClaims)
	exp, _ := claims["exp"].(float64)
	emailVerified, _ := claims["email_verified"].(bool)
	if !emailVerified || time.Unix(int64(exp), 0).Before(time.Now()) {
		return user, fmt.Errorf("%s invalid user information", p.providerName)
	}
	user.Name, _ = claims["name"].(string)
	user.FirstName, _ = claims["given_name"].(string)
	user.LastName, _ = claims["family_name"].(string)
	user.NickName = user.Name
	user.Email, _ = claims["email"].(string)
	user.AvatarURL, _ = claims["picture"].(string)
	user.UserID, _ = claims["sub"].(string)
	return user, nil
}
func ( p * Provider ) FetchUser ( session goth . Session ) ( goth . User , error ) { sess := session . ( * Session ) user := goth . User { AccessToken : sess . AccessToken , Provider : p . Name ( ) , RefreshToken : sess . RefreshToken , ExpiresAt : sess . ExpiresAt , } if user . AccessToken == " " { return user , fmt . Errorf ( " " , p . providerName ) } claims := jwt . MapClaims { } token , _ , err := new ( jwt . Parser ) . ParseUnverified ( sess . IdToken , claims ) if err != nil { return user , err } claims = token . Claims . ( jwt . MapClaims ) exp , _ := claims [ " " ] . ( float64 ) emailVerified , _ := claims [ " " ] . ( bool ) if ! emailVerified || time . Unix ( int64 ( exp ) , 0 ) . Before ( time . Now ( ) ) { return user , fmt . Errorf ( " " , p . providerName ) } user . Name , _ = claims [ " " ] . ( string ) user . FirstName , _ = claims [ " " ] . ( string ) user . LastName , _ = claims [ " " ] . ( string ) user . NickName = user . Name user . Email , _ = claims [ " " ] . ( string ) user . AvatarURL , _ = claims [ " " ] . ( string ) user . UserID , _ = claims [ " " ] . ( string ) return user , nil }
FetchUser will go to Google and access basic information about the user.
FetchUser will go to Google and access basic information about the user .
// Data is not yet retrieved, since accessToken is still empty. /*
	   	pemBlock, _ := pem.Decode([]byte(
	   		`-----BEGIN CERTIFICATE-----
	   MIIF5DCCBMygAwIBAgIRAKnsFF7UVISXCAAAAABL9hAwDQYJKoZIhvcNAQELBQAw
	   QjELMAkGA1UEBhMCVVMxHjAcBgNVBAoTFUdvb2dsZSBUcnVzdCBTZXJ2aWNlczET
	   MBEGA1UEAxMKR1RTIENBIDFPMTAeFw0yMDA3MDcwODA4NTlaFw0yMDA5MjkwODA4
	   NTlaMHExCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQH
	   Ew1Nb3VudGFpbiBWaWV3MRMwEQYDVQQKEwpHb29nbGUgTExDMSAwHgYDVQQDExd1
	   cGxvYWQudmlkZW8uZ29vZ2xlLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IA
	   BNcoqvfoTlhCeqONjWufKahlx+WBaO3fCcdXYq0QBKVDLqnyt6du1XOkWtK9KVOf
	   IXvKblCkgL7/LmkL8++j342jggNvMIIDazAOBgNVHQ8BAf8EBAMCB4AwEwYDVR0l
	   BAwwCgYIKwYBBQUHAwEwDAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUFxJLUXuUrAmg
	   WDftrEejH5aJXFIwHwYDVR0jBBgwFoAUmNH4bhDrz5vsYJ8YkBug630J/SswaAYI
	   KwYBBQUHAQEEXDBaMCsGCCsGAQUFBzABhh9odHRwOi8vb2NzcC5wa2kuZ29vZy9n
	   dHMxbzFjb3JlMCsGCCsGAQUFBzAChh9odHRwOi8vcGtpLmdvb2cvZ3NyMi9HVFMx
	   TzEuY3J0MIIBKwYDVR0RBIIBIjCCAR6CF3VwbG9hZC52aWRlby5nb29nbG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hfKqzqjf
	   VRZhcMTQVK7U4nwGReEhq/ggahv5jE1rDpSb/0gO51FtNbHe03eAC4iZ6juznxlG
	   Y5HOqogsicu9qzVO06jqMa9CM2V9FZwNeM6EGuqot76BZkE7Rs8P2y3Z1Qtagzqg
	   Gw2gi0qdJZXMcnCoVBaf0SJNmDEM0UfM
	   -----END CERTIFICATE-----
	   `))
	   	certs, err := x509.ParseCertificates(pemBlock.Bytes)
	   	if err != nil {
	   		return user, err
	   	}
	   	if len(certs) < 1 {
	   		return user, fmt.Errorf("%s invalid certificate", p.providerName)
	   	}
	   	rsaPublicKey, _ := certs[0].PublicKey.(*rsa.PublicKey)
	   	token, err := jwt.ParseWithClaims(sess.IdToken, claims, func(token *jwt.Token) (interface{}, error) {
	   		return rsaPublicKey, nil
	   	})
	*/ // Extract the user data we got from Google into our goth.User.