当前位置: 首页>>代码示例>>Golang>>正文


Golang User.Email方法代码示例

本文整理汇总了Golang中github.com/markbates/goth.User.Email方法的典型用法代码示例。如果您正苦于以下问题:Golang User.Email方法的具体用法?Golang User.Email怎么用?Golang User.Email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/markbates/goth.User的用法示例。


在下文中一共展示了User.Email方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: userFromReader

// [Private] userFromReader will decode the json user and set the
// *goth.User attributes
func userFromReader(reader io.Reader, user *goth.User) error {
	u := struct {
		ID          string `json:"id"`
		Email       string `json:"email"`
		Name        string `json:"fullname"`
		FirstName   string `json:"first_name"`
		LastName    string `json:"last_name"`
		NickName    string `json:"username"`
		Description string `json:"description"`
		AvatarURL   string `json:"avatar_720_url"`
		Location    string `json:"city"`
	}{}

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

	user.UserID = u.ID
	user.Email = u.Email
	user.Name = u.Name
	user.FirstName = u.FirstName
	user.LastName = u.LastName
	user.NickName = u.NickName
	user.Description = u.Description
	user.AvatarURL = u.AvatarURL
	user.Location = u.Location

	return nil
}
开发者ID:bentranter,项目名称:goth,代码行数:32,代码来源:dailymotion.go

示例2: userFromReader

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
}
开发者ID:sthapaun,项目名称:goth,代码行数:25,代码来源:spotify.go

示例3: userFromReader

func userFromReader(reader io.Reader, user *goth.User) error {
	u := struct {
		ID      string `json:"id"`
		Email   string `json:"email"`
		Bio     string `json:"bio"`
		Name    string `json:"name"`
		Link    string `json:"link"`
		Picture struct {
			Data struct {
				URL string `json:"url"`
			} `json:"data"`
		} `json:"picture"`
		Location struct {
			Name string `json:"name"`
		} `json:"location"`
	}{}

	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.Data.URL
	user.UserID = u.ID
	user.Location = u.Location.Name

	return err
}
开发者ID:rander-oliveira,项目名称:goth,代码行数:32,代码来源:facebook.go

示例4: userFromReader

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
}
开发者ID:rossnanop,项目名称:goth,代码行数:25,代码来源:twitch.go

示例5: userFromReader

func userFromReader(reader io.Reader, user *goth.User) error {

	u := struct {
		ID         string `json:"id"`
		Email      string `json:"emailAddress"`
		FirstName  string `json:"firstName"`
		LastName   string `json:"lastName"`
		Headline   string `json:"headline"`
		PictureURL string `json:"pictureUrl"`
		Location   struct {
			Name string `json:"name"`
		} `json:"location"`
	}{}

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

	user.Name = u.FirstName + " " + u.LastName
	user.NickName = u.FirstName
	user.Email = u.Email
	user.Description = u.Headline
	user.AvatarURL = u.PictureURL
	user.UserID = u.ID
	user.Location = u.Location.Name

	return err
}
开发者ID:rossnanop,项目名称:goth,代码行数:29,代码来源:linkedin.go

示例6: userFromReader

func userFromReader(reader io.Reader, user *goth.User) error {
	u := struct {
		ID        string `json:"id"`
		Email     string `json:"email"`
		Name      string `json:"name"`
		FirstName string `json:"given_name"`
		LastName  string `json:"family_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.FirstName = u.FirstName
	user.LastName = u.LastName
	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
}
开发者ID:bentranter,项目名称:goth,代码行数:28,代码来源:gplus.go

示例7: userFromReader

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
}
开发者ID:bentranter,项目名称:goth,代码行数:26,代码来源:github.go

示例8: populateUser

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
}
开发者ID:rossnanop,项目名称:goth,代码行数:8,代码来源:yammer.go

示例9: userFromReader

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
}
开发者ID:rossnanop,项目名称:goth,代码行数:15,代码来源:heroku.go

示例10: userFromReader

func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Email    string `json:"email"`
		UserName string `json:"user_name"`
		ID       int    `json:"user_id"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email
	user.Name = u.UserName
	user.UserID = strconv.Itoa(u.ID)
	return nil
}
开发者ID:rossnanop,项目名称:goth,代码行数:15,代码来源:wepay.go

示例11: userFromReader

func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Name  string            `json:"name"`
		Email map[string]string `json:"emails"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email["account"]
	user.Name = u.Name
	user.NickName = u.Name
	user.UserID = u.Email["account"] //onedrive doesn't provide separate user_id

	return nil
}
开发者ID:rossnanop,项目名称:goth,代码行数:16,代码来源:onedrive.go

示例12: buildUserObject

// 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
}
开发者ID:rossnanop,项目名称:goth,代码行数:49,代码来源:steam.go

示例13: userFromReader

func userFromReader(r io.Reader, user *goth.User) error {
	u := struct {
		Name      string `json:"first_name"`
		Email     string `json:"email"`
		ID        string `json:"uuid"`
		AvatarURL string `json:"picture"`
	}{}
	err := json.NewDecoder(r).Decode(&u)
	if err != nil {
		return err
	}
	user.Email = u.Email
	user.Name = u.Name
	user.UserID = u.ID
	user.AvatarURL = u.AvatarURL
	return nil
}
开发者ID:rossnanop,项目名称:goth,代码行数:17,代码来源:uber.go

示例14: userFromReader

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
}
开发者ID:rossnanop,项目名称:goth,代码行数:18,代码来源:amazon.go

示例15: emailFromReader

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
}
开发者ID:drathier,项目名称:goth,代码行数:18,代码来源:bitbucket.go


注:本文中的github.com/markbates/goth.User.Email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。