Skip to content

Commit 691fffc

Browse files
committed
Get user full name from Apple Sign-In
1 parent 4f0f726 commit 691fffc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

providers/apple/apple.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,12 @@ func (Provider) UnmarshalSession(data string) (goth.Session, error) {
121121
return s, err
122122
}
123123

124-
// Apple doesn't seem to provide a user profile endpoint like all the other providers do.
125-
// Therefore this will return a User with the unique identifier obtained through authorization
126-
// as the only identifying attribute.
127124
// A full name and email can be obtained from the form post response (parameter 'user')
128125
// to the redirect page following authentication, if the name and email scopes are requested.
129126
// Additionally, if the response type is form_post and the email scope is requested, the email
130127
// will be encoded into the ID token in the email claim.
128+
// Note that the full name is only provided on the very first authentication of a user, and
129+
// subsequent authentications will not include the full name, even if requested.
131130
func (p Provider) FetchUser(session goth.Session) (goth.User, error) {
132131
s := session.(*Session)
133132
if s.AccessToken == "" {

providers/apple/session.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func (s *Session) Authorize(provider goth.Provider, params goth.Params) (string,
122122
EmailVerified: idToken.Claims.(*IDTokenClaims).EmailVerified.Value(),
123123
}
124124

125+
// fetch the user first and last name from the params if available.
125126
if user := params.Get("user"); user != "" {
126127
var userData struct {
127128
Name struct {

0 commit comments

Comments
 (0)