Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tokenauth example as debugging tool #1853

Merged
merged 2 commits into from
Apr 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions example/tokenauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/v35/github"
Expand All @@ -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))
}