Skip to content

Instantly share code, notes, and snippets.

@dotdoom
Last active July 11, 2016 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dotdoom/639f72d446f4e9c6b32404356ab1f730 to your computer and use it in GitHub Desktop.
Save dotdoom/639f72d446f4e9c6b32404356ab1f730 to your computer and use it in GitHub Desktop.
Verify Google-issued OAuth2 token in Go
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