Skip to content

Instantly share code, notes, and snippets.

@yfuruyama
Created October 27, 2018 14:26
Show Gist options
  • Select an option

  • Save yfuruyama/c00e5c9e9e8f0ff0d02a1f6e8817f574 to your computer and use it in GitHub Desktop.

Select an option

Save yfuruyama/c00e5c9e9e8f0ff0d02a1f6e8817f574 to your computer and use it in GitHub Desktop.
Show token info
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strings"
)
func main() {
tokenBytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}
token := string(tokenBytes)
token = strings.TrimSuffix(token, "\n")
resp, err := http.Get("https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=" + token)
if err != nil {
log.Fatal(err)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Print(string(body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment