Skip to content

Commit c9ba0b1

Browse files
committed
fix: update scope for apple login
1 parent fadd9f6 commit c9ba0b1

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

server/handlers/oauth_callback.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ func processAppleUserInfo(code string) (models.User, error) {
492492
fmt.Println("=> claims", claims)
493493

494494
if val, ok := claims["email"]; !ok {
495-
log.Debug("Failed to extract email from claims")
496-
return user, fmt.Errorf("unable to extract email")
495+
log.Debug("Failed to extract email from claims.")
496+
return user, fmt.Errorf("unable to extract email, please check the scopes enabled for your app. It needs `email`, `name` scopes")
497497
} else {
498498
user.Email = val.(string)
499499
}

server/handlers/oauth_login.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ func OAuthLoginHandler() gin.HandlerFunc {
184184
return
185185
}
186186
oauth.OAuthProviders.AppleConfig.RedirectURL = hostname + "/oauth_callback/" + constants.SignupMethodApple
187-
url := oauth.OAuthProviders.AppleConfig.AuthCodeURL(oauthStateString, oauth2.SetAuthURLParam("response_mode", "form_post"))
187+
// Scope from the root config was not passed for apple login
188+
url := oauth.OAuthProviders.AppleConfig.AuthCodeURL(oauthStateString, oauth2.SetAuthURLParam("response_mode", "form_post"), oauth2.SetAuthURLParam("scope", "name email"))
188189
c.Redirect(http.StatusTemporaryRedirect, url)
189190
default:
190191
log.Debug("Invalid oauth provider: ", provider)

server/oauth/oauth.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ func InitOAuth() error {
130130
AuthURL: "https://appleid.apple.com/auth/authorize",
131131
TokenURL: "https://appleid.apple.com/auth/token",
132132
},
133-
Scopes: []string{"openid", "name", "email"},
134133
}
135134
}
136135

0 commit comments

Comments
 (0)