예제 #1
0
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Country     string `json:"country"`
		DisplayName string `json:"display_name"`
		Email       string `json:"email"`
		ID          string `json:"id"`
		Images      []struct {
			URL string `json:"url"`
		} `json:"images"`
	}{}

	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}

	user.Name = u.DisplayName
	user.Email = u.Email
	user.UserID = u.ID
	user.Location = u.Country
	if len(u.Images) > 0 {
		user.AvatarURL = u.Images[0].URL
	}
	return nil
}
예제 #2
0
func userFromReader(reader io.Reader, user *goth.User) error {
	u := struct {
		ID       int    `json:"id"`
		Email    string `json:"email"`
		Bio      string `json:"bio"`
		Name     string `json:"name"`
		Login    string `json:"login"`
		Picture  string `json:"avatar_url"`
		Location string `json:"location"`
	}{}

	err := json.NewDecoder(reader).Decode(&u)
	if err != nil {
		return err
	}

	user.Name = u.Name
	user.NickName = u.Login
	user.Email = u.Email
	user.Description = u.Bio
	user.AvatarURL = u.Picture
	user.UserID = strconv.Itoa(u.ID)
	user.Location = u.Location

	return err
}
예제 #3
0
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Name        string `json:"name"`
		Email       string `json:"email"`
		Nickname    string `json:"display_name"`
		AvatarURL   string `json:"logo"`
		Description string `json:"bio"`
		ID          int    `json:"_id"`
	}{}

	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}

	user.Name = u.Name
	user.Email = u.Email
	user.NickName = u.Nickname
	user.Location = "No location is provided by the Twitch API"
	user.AvatarURL = u.AvatarURL
	user.Description = u.Description
	user.UserID = strconv.Itoa(u.ID)

	return nil
}
예제 #4
0
func populateUser(userMap map[string]interface{}, user *goth.User) error {
	user.Email = stringValue(userMap["email"])
	user.Name = stringValue(userMap["full_name"])
	user.NickName = stringValue(userMap["full_name"])
	user.UserID = strconv.FormatFloat(userMap["id"].(float64), 'f', -1, 64)
	user.Location = stringValue(userMap["location"])
	return nil
}
예제 #5
0
파일: heroku.go 프로젝트: jonnonz1/goth
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Name  string `json:"name"`
		Email string `json:"email"`
		ID    string `json:"id"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email
	user.Name = u.Name
	user.UserID = u.ID
	return nil
}
예제 #6
0
// buildUserObject is an internal function to build a goth.User object
// based in the data stored in r
func buildUserObject(r io.Reader, u goth.User) (goth.User, error) {
	// Response object from Steam
	apiResponse := struct {
		Response struct {
			Players []struct {
				UserID              string `json:"steamid"`
				NickName            string `json:"personaname"`
				Name                string `json:"realname"`
				AvatarURL           string `json:"avatarfull"`
				LocationCountryCode string `json:"loccountrycode"`
				LocationStateCode   string `json:"locstatecode"`
			} `json:"players"`
		} `json:"response"`
	}{}

	err := json.NewDecoder(r).Decode(&apiResponse)
	if err != nil {
		return u, err
	}

	if l := len(apiResponse.Response.Players); l != 1 {
		return u, fmt.Errorf("Expected one player in API response. Got %d.", l)
	}

	player := apiResponse.Response.Players[0]
	u.UserID = player.UserID
	u.Name = player.Name
	if len(player.Name) == 0 {
		u.Name = "No name is provided by the Steam API"
	}
	u.NickName = player.NickName
	u.AvatarURL = player.AvatarURL
	u.Email = "No email is provided by the Steam API"
	u.Description = "No description is provided by the Steam API"

	if len(player.LocationStateCode) > 0 && len(player.LocationCountryCode) > 0 {
		u.Location = fmt.Sprintf("%s, %s", player.LocationStateCode, player.LocationCountryCode)
	} else if len(player.LocationCountryCode) > 0 {
		u.Location = player.LocationCountryCode
	} else if len(player.LocationStateCode) > 0 {
		u.Location = player.LocationStateCode
	} else {
		u.Location = "No location is provided by the Steam API"
	}

	return u, nil
}
예제 #7
0
파일: amazon.go 프로젝트: jonnonz1/goth
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Name     string `json:"name"`
		Location string `json:"postal_code"`
		Email    string `json:"email"`
		ID       string `json:"user_id"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email
	user.Name = u.Name
	user.NickName = u.Name
	user.UserID = u.ID
	user.Location = u.Location
	return nil
}
예제 #8
0
파일: bitbucket.go 프로젝트: jonnonz1/goth
func emailFromReader(reader io.Reader, user *goth.User) error {
	e := struct {
		Values []struct {
			Email string `json:"email"`
		} `json:"values"`
	}{}

	err := json.NewDecoder(reader).Decode(&e)
	if err != nil {
		return err
	}

	if len(e.Values) > 0 {
		user.Email = e.Values[0].Email
	}

	return err
}
예제 #9
0
파일: box.go 프로젝트: jonnonz1/goth
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Name      string `json:"name"`
		Location  string `json:"address"`
		Email     string `json:"login"`
		AvatarURL string `json:"avatar_url"`
		ID        string `json:"id"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email
	user.Name = u.Name
	user.NickName = u.Name
	user.UserID = u.ID
	user.Location = u.Location
	return nil
}
예제 #10
0
파일: gitlab.go 프로젝트: jonnonz1/goth
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Name      string `json:"name"`
		Email     string `json:"email"`
		NickName  string `json:"username"`
		ID        int    `json:"id"`
		AvatarURL string `json:"avatar_url"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email
	user.Name = u.Name
	user.NickName = u.NickName
	user.UserID = strconv.Itoa(u.ID)
	user.AvatarURL = u.AvatarURL
	return nil
}
예제 #11
0
파일: salesforce.go 프로젝트: jonnonz1/goth
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Name      string `json:"display_name"`
		NickName  string `json:"nick_name"`
		Location  string `json:"addr_country"`
		Email     string `json:"email"`
		AvatarURL string `json:"photos.picture"`
		ID        string `json:"user_id"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email
	user.Name = u.Name
	user.NickName = u.Name
	user.UserID = u.ID
	user.Location = u.Location
	return nil
}
예제 #12
0
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Email     string `json:"email"`
		Name      string `json:"display_name"`
		AvatarURL string `json:"business_logo"`
		ID        string `json:"id"`
		Address   struct {
			Location string `json:"city"`
		} `json:"support_address"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email //email is not provided by yahoo
	user.Name = u.Name
	user.NickName = u.Name
	user.UserID = u.ID
	user.Location = u.Address.Location
	user.AvatarURL = u.AvatarURL
	return nil
}
예제 #13
0
func userFromReader(reader io.Reader, user *goth.User) error {
	u := struct {
		Account struct {
			DropletLimit  int    `json:"droplet_limit"`
			Email         string `json:"email"`
			UUID          string `json:"uuid"`
			EmailVerified bool   `json:"email_verified"`
			Status        string `json:"status"`
			StatusMessage string `json:"status_message"`
		} `json:"account"`
	}{}

	err := json.NewDecoder(reader).Decode(&u)
	if err != nil {
		return err
	}

	user.Email = u.Account.Email
	user.UserID = u.Account.UUID

	return err
}
예제 #14
0
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		User struct {
			NickName string `json:"name"`
			ID       string `json:"id"`
			Profile  struct {
				Email     string `json:"email"`
				Name      string `json:"real_name"`
				AvatarURL string `json:"image_32"`
			} `json:"profile"`
		} `json:"user"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.User.Profile.Email
	user.Name = u.User.Profile.Name
	user.NickName = u.User.NickName
	user.UserID = u.User.ID
	user.AvatarURL = u.User.Profile.AvatarURL
	return nil
}
예제 #15
0
func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Profile struct {
			NickName string `json:"nickname"`
			Location string `json:"location"`
			ID       string `json:"guid"`
			Image    struct {
				ImageURL string `json:"imageURL"`
			} `json:"image"`
		} `json:"profile"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = "" //email is not provided by yahoo
	user.Name = u.Profile.NickName
	user.NickName = u.Profile.NickName
	user.UserID = u.Profile.ID
	user.Location = u.Profile.Location
	user.AvatarURL = u.Profile.Image.ImageURL
	return nil
}
예제 #16
0
파일: gplus.go 프로젝트: jonnonz1/goth
func userFromReader(reader io.Reader, user *goth.User) error {
	u := struct {
		ID      string `json:"id"`
		Email   string `json:"email"`
		Name    string `json:"name"`
		Link    string `json:"link"`
		Picture string `json:"picture"`
	}{}

	err := json.NewDecoder(reader).Decode(&u)
	if err != nil {
		return err
	}

	user.Name = u.Name
	user.NickName = u.Name
	user.Email = u.Email
	//user.Description = u.Bio
	user.AvatarURL = u.Picture
	user.UserID = u.ID
	//user.Location = u.Location.Name

	return err
}