Fix vet
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Meutel 2019-09-11 17:26:32 +02:00
parent 877b37f945
commit 128fd33a26
4 changed files with 9 additions and 4 deletions

View File

@ -61,7 +61,11 @@ func (p GiteaProvider) Config(conf *Conf) *oauth2.Config {
ClientID: c.ClientID,
ClientSecret: c.ClientSecret,
RedirectURL: conf.ExternalURL + "/callback",
Endpoint: oauth2.Endpoint{c.AuthURL, c.TokenURL, oauth2.AuthStyleAutoDetect},
Endpoint: oauth2.Endpoint{
AuthURL: c.AuthURL,
TokenURL: c.TokenURL,
AuthStyle: oauth2.AuthStyleAutoDetect,
},
}
}
}
@ -75,11 +79,11 @@ func (p GiteaProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, erro
apiReq.Header.Add("Authorization", "token "+token.AccessToken)
client := &http.Client{}
response, err := client.Do(apiReq)
defer response.Body.Close()
if err != nil {
log.Println("Auth error", err)
return "", fmt.Errorf("Authentification error")
}
defer response.Body.Close()
dec := json.NewDecoder(response.Body)
var profile giteaProfile

View File

@ -61,11 +61,11 @@ func (p GithubProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, err
apiReq.Header.Add("Authorization", "token "+token.AccessToken)
client := &http.Client{}
response, err := client.Do(apiReq)
defer response.Body.Close()
if err != nil {
log.Println("Auth error", err)
return "", fmt.Errorf("Authentification error")
}
defer response.Body.Close()
dec := json.NewDecoder(response.Body)
var emails []githubEmail

View File

@ -62,11 +62,11 @@ func (p GoogleProvider) Config(conf *Conf) *oauth2.Config {
// GetUser returns github primary email
func (p GoogleProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, error) {
apiRes, err := http.Post("https://www.googleapis.com/oauth2/v2/tokeninfo?access_token="+token.AccessToken, "application/json", nil)
defer apiRes.Body.Close()
if err != nil {
log.Println("Auth error", err)
return "", fmt.Errorf("Authentification error")
}
defer apiRes.Body.Close()
dec := json.NewDecoder(apiRes.Body)
var tokenInfo googleTokenInfo
err = dec.Decode(&tokenInfo)

1
go.sum
View File

@ -16,6 +16,7 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=