本文整理汇总了Golang中github.com/markbates/goth.User类的典型用法代码示例。如果您正苦于以下问题:Golang User类的具体用法?Golang User怎么用?Golang User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
Data struct {
ID string `json:"id"`
UserName string `json:"username"`
FullName string `json:"full_name"`
ProfilePicture string `json:"profile_picture"`
Bio string `json:"bio"`
Website string `json:"website"`
Counts struct {
Media int `json:"media"`
Follows int `json:"follows"`
FollowedBy int `json:"followed_by"`
} `json:"counts"`
} `json:"data"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Data.UserName
user.NickName = u.Data.UserName
user.AvatarURL = u.Data.ProfilePicture
user.Description = u.Data.Bio
return err
}
示例3: userFromReader
func userFromReader(reader io.Reader, user *goth.User) error {
u := struct {
ID string `json:"uuid"`
Links struct {
Avatar struct {
URL string `json:"href"`
} `json:"avatar"`
} `json:"links"`
Email string `json:"email"`
Username string `json:"username"`
Name string `json:"display_name"`
Location string `json:"location"`
}{}
err := json.NewDecoder(reader).Decode(&u)
if err != nil {
return err
}
user.Name = u.Name
user.NickName = u.Username
user.AvatarURL = u.Links.Avatar.URL
user.UserID = u.ID
user.Location = u.Location
return err
}
示例4: 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
}
示例5: 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
}
示例6: FetchUser
// FetchUser will go to Twitter and access basic information about the user.
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
user := goth.User{
Provider: p.Name(),
}
sess := session.(*Session)
response, err := p.consumer.Get(
endpointProfile,
map[string]string{"include_entities": "false", "skip_status": "true"},
sess.AccessToken)
if err != nil {
return user, err
}
defer response.Body.Close()
bits, err := ioutil.ReadAll(response.Body)
err = json.NewDecoder(bytes.NewReader(bits)).Decode(&user.RawData)
if err != nil {
return user, err
}
user.Name = user.RawData["name"].(string)
user.NickName = user.RawData["screen_name"].(string)
user.Description = user.RawData["description"].(string)
user.AvatarURL = user.RawData["profile_image_url"].(string)
user.UserID = user.RawData["id_str"].(string)
user.Location = user.RawData["location"].(string)
user.AccessToken = sess.AccessToken.Token
user.AccessTokenSecret = sess.AccessToken.Secret
return user, err
}
示例7: 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
}
示例8: 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
}
示例9: 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
}
示例10: 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
}
示例11: 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
}
示例12: 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
}
示例13: 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
}
示例14: 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
}
示例15: 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
}