@@ -15,7 +15,7 @@ import (
1515const (
1616 authURL string = "https://api.login.yahoo.com/oauth2/request_auth"
1717 tokenURL string = "https://api.login.yahoo.com/oauth2/get_token"
18- endpointProfile string = "https://social.yahooapis. com/v1/user/GUID/profile?format=json "
18+ endpointProfile string = "https://api.login.yahoo. com/openid/ v1/userinfo "
1919)
2020
2121// Provider is the implementation of `goth.Provider` for accessing Yahoo.
@@ -123,27 +123,29 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config {
123123 return c
124124}
125125
126+ type yahooUser struct {
127+ Email string `json:"email"`
128+ Name string `json:"name"`
129+ GivenName string `json:"given_name"`
130+ FamilyName string `json:"family_name"`
131+ Nickname string `json:"nickname"`
132+ Picture string `json:"picture"`
133+ Sub string `json:"sub"`
134+ }
135+
126136func userFromReader (r io.Reader , user * goth.User ) error {
127- u := struct {
128- Profile struct {
129- NickName string `json:"nickname"`
130- Location string `json:"location"`
131- ID string `json:"guid"`
132- Image struct {
133- ImageURL string `json:"imageURL"`
134- } `json:"image"`
135- } `json:"profile"`
136- }{}
137+ u := yahooUser {}
137138 err := json .NewDecoder (r ).Decode (& u )
138139 if err != nil {
139140 return err
140141 }
141- user .Email = "" // email is not provided by yahoo
142- user .Name = u .Profile .NickName
143- user .NickName = u .Profile .NickName
144- user .UserID = u .Profile .ID
145- user .Location = u .Profile .Location
146- user .AvatarURL = u .Profile .Image .ImageURL
142+ user .Email = u .Email
143+ user .Name = u .Name
144+ user .FirstName = u .GivenName
145+ user .LastName = u .FamilyName
146+ user .NickName = u .Nickname
147+ user .AvatarURL = u .Picture
148+ user .UserID = u .Sub
147149 return nil
148150}
149151
0 commit comments