From 473a365f582855420c01e2085a7fef5b9eb034ef Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Fri, 9 Apr 2021 06:35:27 -0400 Subject: [PATCH] Improve tokenauth example as debugging tool --- example/tokenauth/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/example/tokenauth/main.go b/example/tokenauth/main.go index ff92db2ada7..97166cd7244 100644 --- a/example/tokenauth/main.go +++ b/example/tokenauth/main.go @@ -4,11 +4,14 @@ // license that can be found in the LICENSE file. // The tokenauth command demonstrates using the oauth2.StaticTokenSource. +// You can test out a GitHub Personal Access Token using this simple example. +// You can generate them here: https://github.com/settings/tokens package main import ( "context" "fmt" + "log" "syscall" "github.com/google/go-github/v34/github" @@ -29,12 +32,14 @@ func main() { client := github.NewClient(tc) - user, _, err := client.Users.Get(ctx, "") - + user, resp, err := client.Users.Get(ctx, "") if err != nil { fmt.Printf("\nerror: %v\n", err) return } + // Rate.Limit should most likely be 5000 when authorized. + log.Printf("Rate: %#v", resp.Rate) + fmt.Printf("\n%v\n", github.Stringify(user)) }