fix: update scope for apple login

This commit is contained in:
Lakhan Samani 2022-06-14 12:35:23 +05:30
parent 6335084835
commit 395e2e2a85
2 changed files with 16 additions and 5 deletions

View File

@ -482,15 +482,26 @@ func processAppleUserInfo(code string) (models.User, error) {
} }
fmt.Println("=> decoded claims data", decodedClaimsData) fmt.Println("=> decoded claims data", decodedClaimsData)
claims := map[string]string{} claims := make(map[string]interface{})
err = json.Unmarshal([]byte(decodedClaimsData), &claims) err = json.Unmarshal([]byte(decodedClaimsData), &claims)
if err != nil { if err != nil {
log.Debug("Failed to unmarshal claims data: ", err) log.Debug("Failed to unmarshal claims data: ", err)
return user, fmt.Errorf("failed to unmarshal claims data: %s", err.Error()) return user, fmt.Errorf("failed to unmarshal claims data: %s", err.Error())
} }
fmt.Println("=> claims map:", claims)
email := claims["email"] fmt.Println("=> claims", claims)
user.Email = email
if val, ok := claims["email"]; !ok {
log.Debug("Failed to extract email from claims")
return user, fmt.Errorf("unable to extract email")
} else {
user.Email = val.(string)
}
if val, ok := claims["name"]; ok {
givenName := val.(string)
user.GivenName = &givenName
}
return user, err return user, err
} }

View File

@ -130,7 +130,7 @@ func InitOAuth() error {
AuthURL: "https://appleid.apple.com/auth/authorize", AuthURL: "https://appleid.apple.com/auth/authorize",
TokenURL: "https://appleid.apple.com/auth/token", TokenURL: "https://appleid.apple.com/auth/token",
}, },
Scopes: []string{"email"}, Scopes: []string{"name", "email"},
} }
} }