16
github.go
16
github.go
@@ -6,7 +6,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"code.google.com/p/goauth2/oauth"
|
"golang.org/x/oauth2"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
)
|
)
|
||||||
@@ -37,18 +37,16 @@ type GitHubClient struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewGitHubClient(source Source) (*GitHubClient, error) {
|
func NewGitHubClient(source Source) (*GitHubClient, error) {
|
||||||
transport := &oauth.Transport{
|
|
||||||
Token: &oauth.Token{
|
|
||||||
AccessToken: source.AccessToken,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
var client *github.Client
|
var client *github.Client
|
||||||
|
|
||||||
if transport.Token.AccessToken == "" {
|
if source.AccessToken == "" {
|
||||||
client = github.NewClient(nil)
|
client = github.NewClient(nil)
|
||||||
} else {
|
} else {
|
||||||
client = github.NewClient(transport.Client())
|
ts := oauth2.StaticTokenSource(&oauth2.Token{
|
||||||
|
AccessToken: source.AccessToken,
|
||||||
|
})
|
||||||
|
|
||||||
|
client = github.NewClient(oauth2.NewClient(oauth2.NoContext, ts))
|
||||||
}
|
}
|
||||||
|
|
||||||
if source.GitHubAPIURL != "" {
|
if source.GitHubAPIURL != "" {
|
||||||
|
Reference in New Issue
Block a user