MCPcopy Create free account
hub / github.com/google/go-github / main

Function main

example/tokenauth/main.go:22–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20)
21
22func main() {
23 fmt.Print("GitHub Token: ")
24 token, _ := term.ReadPassword(int(os.Stdin.Fd()))
25 fmt.Println()
26
27 ctx := context.Background()
28 client, err := github.NewClient(github.WithAuthToken(string(token)))
29 if err != nil {
30 log.Fatalf("Error creating GitHub client: %v", err)
31 }
32
33 user, resp, err := client.Users.Get(ctx, "")
34 if err != nil {
35 log.Fatalf("Error fetching user: %v", err)
36 }
37
38 // Rate.Limit should most likely be 5000 when authorized.
39 log.Printf("Rate: %#v\n", resp.Rate)
40
41 // If a Token Expiration has been set, it will be displayed.
42 if !resp.TokenExpiration.IsZero() {
43 log.Printf("Token Expiration: %v\n", resp.TokenExpiration)
44 }
45
46 fmt.Printf("\n%v\n", github.Stringify(user))
47}

Callers

nothing calls this directly

Calls 4

NewClientFunction · 0.92
WithAuthTokenFunction · 0.92
StringifyFunction · 0.92
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…