10
type yandexResourceOwner struct {
14
func (yro *yandexResourceOwner) GetUserData() (*UserData, error) {
15
request, err := http.NewRequest(http.MethodGet, "https://login.yandex.ru/info", http.NoBody)
20
request.Header.Set("Accept", "application/json")
21
request.Header.Set("Authorization", "OAuth "+yro.accessToken)
23
buf, err := doRequest(request)
29
return nil, errors.New("invalid JSON string")
34
Username string `json:"login"`
35
DisplayName string `json:"display_name"`
36
FirstName string `json:"first_name"`
37
LastName string `json:"last_name"`
38
Gender Gender `json:"sex"`
39
Email string `json:"default_email"`
40
Avatar string `json:"default_avatar_id"`
41
IsAvatarEmpty bool `json:"is_avatar_empty"`
46
err = json.Unmarshal(buf, &result)
51
userData := &UserData{
53
Username: result.Username,
54
DisplayName: result.DisplayName,
55
FirstName: result.FirstName,
56
LastName: result.LastName,
57
Gender: result.Gender,
59
RawData: base64.URLEncoding.EncodeToString(buf),
60
Provider: yandexProvider,
63
if !result.IsAvatarEmpty {
64
userData.Avatar = result.Avatar