Last active
July 11, 2016 11:05
-
-
Save dotdoom/639f72d446f4e9c6b32404356ab1f730 to your computer and use it in GitHub Desktop.
Verify Google-issued OAuth2 token in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"google.golang.org/api/oauth2/v2" | |
) | |
func main() { | |
svc, e := oauth2.New(http.DefaultClient) | |
if e != nil { | |
log.Fatal(e) | |
} | |
ti, e := svc.Tokeninfo().IdToken("<token here>").Do() | |
if e != nil { | |
log.Fatal(e) | |
} | |
fmt.Println(ti.Email) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment