@@ -60,7 +60,7 @@ func (f *GithubDownloaderV3Factory) New(opts base.MigrateOptions) (base.Download
60
60
61
61
log .Trace ("Create github downloader: %s/%s" , oldOwner , oldName )
62
62
63
- return NewGithubDownloaderV3 (opts .AuthUsername , opts .AuthPassword , oldOwner , oldName ), nil
63
+ return NewGithubDownloaderV3 (opts .AuthUsername , opts .AuthPassword , opts . AuthToken , oldOwner , oldName ), nil
64
64
}
65
65
66
66
// GitServiceType returns the type of git service
@@ -81,7 +81,7 @@ type GithubDownloaderV3 struct {
81
81
}
82
82
83
83
// NewGithubDownloaderV3 creates a github Downloader via github v3 API
84
- func NewGithubDownloaderV3 (userName , password , repoOwner , repoName string ) * GithubDownloaderV3 {
84
+ func NewGithubDownloaderV3 (userName , password , token , repoOwner , repoName string ) * GithubDownloaderV3 {
85
85
var downloader = GithubDownloaderV3 {
86
86
userName : userName ,
87
87
password : password ,
@@ -90,23 +90,19 @@ func NewGithubDownloaderV3(userName, password, repoOwner, repoName string) *Gith
90
90
repoName : repoName ,
91
91
}
92
92
93
- var client * http.Client
94
- if userName != "" {
95
- if password == "" {
96
- ts := oauth2 .StaticTokenSource (
97
- & oauth2.Token {AccessToken : userName },
98
- )
99
- client = oauth2 .NewClient (downloader .ctx , ts )
100
- } else {
101
- client = & http.Client {
102
- Transport : & http.Transport {
103
- Proxy : func (req * http.Request ) (* url.URL , error ) {
104
- req .SetBasicAuth (userName , password )
105
- return nil , nil
106
- },
107
- },
108
- }
109
- }
93
+ client := & http.Client {
94
+ Transport : & http.Transport {
95
+ Proxy : func (req * http.Request ) (* url.URL , error ) {
96
+ req .SetBasicAuth (userName , password )
97
+ return nil , nil
98
+ },
99
+ },
100
+ }
101
+ if token != "" {
102
+ ts := oauth2 .StaticTokenSource (
103
+ & oauth2.Token {AccessToken : token },
104
+ )
105
+ client = oauth2 .NewClient (downloader .ctx , ts )
110
106
}
111
107
downloader .client = github .NewClient (client )
112
108
return & downloader
0 commit comments