-
Notifications
You must be signed in to change notification settings - Fork 0
/
undefined.go
50 lines (39 loc) · 1.07 KB
/
undefined.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*This is us trying to break simple text/low-level repo parts of Github (and obviously report our findings to them)
- help us & GitHub by submitting a PR!*/
package main
import (
"encoding/json"
"fmt"
"github.com/google/go-github/github"
"golang.org/x/oauth2"
)
var (
personalAccessToken = "undefined"
)
type TokenSource struct {
AccessToken string
}
func (t *TokenSource) Token() (*oauth2.Token, error) {
token := &oauth2.Token{
AccessToken: t.AccessToken,
}
return token, nil
}
func main() {
tokenSource := &TokenSource{
AccessToken: personalAccessToken,
}
paOauthToken := oauth2.NewClient(oauth2.NoContext, tokenSource)
client := github.NewClient(paOauthToken)
user, _, err := client.Users.Get("undefined")
if err != nil {
fmt.Printf("client.Users.Get() faled with '%s'\n", err)
return
}
d, err := json.MarshalIndent(user, "", " ")
if err != nil {
fmt.Printf("json.MarshlIndent() failed with %s\n", err)
return
}
fmt.Printf("User:\n%s\n", string(d))
}