add refresh to client as well

This commit is contained in:
Matti Ranta 2019-04-22 20:09:40 -04:00
parent 6adbacd11c
commit b2d850f16f
No known key found for this signature in database
GPG key ID: D9B5613BEB813F99

View file

@ -117,10 +117,25 @@ func provideGiteaClient(config config.Config) *scm.Client {
if config.Gitea.Debug {
client.DumpResponse = httputil.DumpResponse
}
if config.Gitea.ClientID == "" {
client.Client = &http.Client{
Transport: &oauth2.Transport{
Scheme: oauth2.SchemeToken,
Source: oauth2.ContextTokenSource(),
Base: defaultTransport(config.Gitea.SkipVerify),
},
}
return client
}
client.Client = &http.Client{
Transport: &oauth2.Transport{
Scheme: oauth2.SchemeToken,
Source: oauth2.ContextTokenSource(),
Scheme: oauth2.SchemeBearer,
Source: &oauth2.Refresher{
ClientID: config.Gitea.ClientID,
ClientSecret: config.Gitea.ClientSecret,
Endpoint: config.Gitea.Server + "/login/oauth/access_token",
Source: oauth2.ContextTokenSource(),
},
Base: defaultTransport(config.Gitea.SkipVerify),
},
}