Added OAuth2 token refresher for Gitlab (#3215)
This commit is contained in:
parent
f7a3c375a2
commit
b6053394ef
2 changed files with 15 additions and 1 deletions
|
@ -180,7 +180,13 @@ func provideGitlabClient(config config.Config) *scm.Client {
|
|||
}
|
||||
client.Client = &http.Client{
|
||||
Transport: &oauth2.Transport{
|
||||
Scheme: oauth2.SchemeBearer,
|
||||
Source: &oauth2.Refresher{
|
||||
ClientID: config.GitLab.ClientID,
|
||||
ClientSecret: config.GitLab.ClientSecret,
|
||||
Endpoint: strings.TrimSuffix(config.GitLab.Server, "/") + "/oauth/token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
},
|
||||
Base: defaultTransport(config.GitLab.SkipVerify),
|
||||
},
|
||||
}
|
||||
|
|
|
@ -197,6 +197,14 @@ func provideRefresher(config config.Config) *oauth2.Refresher {
|
|||
Source: oauth2.ContextTokenSource(),
|
||||
Client: defaultClient(config.Gitea.SkipVerify),
|
||||
}
|
||||
case config.GitLab.ClientID != "":
|
||||
return &oauth2.Refresher{
|
||||
ClientID: config.GitLab.ClientID,
|
||||
ClientSecret: config.GitLab.ClientSecret,
|
||||
Endpoint: strings.TrimSuffix(config.GitLab.Server, "/") + "/oauth/token",
|
||||
Source: oauth2.ContextTokenSource(),
|
||||
Client: defaultClient(config.GitLab.SkipVerify),
|
||||
}
|
||||
case config.Gitee.ClientID != "":
|
||||
return &oauth2.Refresher{
|
||||
ClientID: config.Gitee.ClientID,
|
||||
|
|
Loading…
Reference in a new issue