fix: scope for github auth
This commit is contained in:
parent
ed849fa6f6
commit
993693884d
|
@ -287,9 +287,9 @@ func processGithubUserInfo(code string) (models.User, error) {
|
||||||
log.Debug("Failed to create github user info request: ", err)
|
log.Debug("Failed to create github user info request: ", err)
|
||||||
return user, fmt.Errorf("error creating github user info request: %s", err.Error())
|
return user, fmt.Errorf("error creating github user info request: %s", err.Error())
|
||||||
}
|
}
|
||||||
req.Header = http.Header{
|
req.Header.Set(
|
||||||
"Authorization": []string{fmt.Sprintf("token %s", oauth2Token.AccessToken)},
|
"Authorization", fmt.Sprintf("token %s", oauth2Token.AccessToken),
|
||||||
}
|
)
|
||||||
|
|
||||||
response, err := client.Do(req)
|
response, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -331,14 +331,14 @@ func processGithubUserInfo(code string) (models.User, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch using /users/email endpoint
|
// fetch using /users/email endpoint
|
||||||
req, err := http.NewRequest("GET", constants.GithubUserEmails, nil)
|
req, err := http.NewRequest(http.MethodGet, constants.GithubUserEmails, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("Failed to create github emails request: ", err)
|
log.Debug("Failed to create github emails request: ", err)
|
||||||
return user, fmt.Errorf("error creating github user info request: %s", err.Error())
|
return user, fmt.Errorf("error creating github user info request: %s", err.Error())
|
||||||
}
|
}
|
||||||
req.Header = http.Header{
|
req.Header.Set(
|
||||||
"Authorization": []string{fmt.Sprintf("token %s", oauth2Token.AccessToken)},
|
"Authorization", fmt.Sprintf("token %s", oauth2Token.AccessToken),
|
||||||
}
|
)
|
||||||
|
|
||||||
response, err := client.Do(req)
|
response, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -75,6 +75,7 @@ func InitOAuth() error {
|
||||||
ClientSecret: githubClientSecret,
|
ClientSecret: githubClientSecret,
|
||||||
RedirectURL: "/oauth_callback/github",
|
RedirectURL: "/oauth_callback/github",
|
||||||
Endpoint: githubOAuth2.Endpoint,
|
Endpoint: githubOAuth2.Endpoint,
|
||||||
|
Scopes: []string{"read:user", "user:email"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user