// FetchUser will go to Twitter and access basic information about the user. func (p *Provider) FetchUser(session goth.Session) (*goth.User, error) { sess := session.(*Session) response, err := p.consumer.Get( endpointProfile, map[string]string{"include_entities": "false", "skip_status": "true"}, sess.AccessToken) if err != nil { return nil, err } defer response.Body.Close() bits, err := ioutil.ReadAll(response.Body) if err != nil { return nil, err } user := goth.User{} err = json.NewDecoder(bytes.NewReader(bits)).Decode(&user.RawData) if err != nil { return nil, 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 }
// FetchUser will go to Tumblr and access basic information about the user. func (p *Provider) FetchUser(session goth.Session) (*goth.User, error) { user := goth.User{} sess := session.(*Session) response, err := p.consumer.Get( endpointProfile, map[string]string{ "method": "flickr.people.getInfo", "format": "json", "nojsoncallback": "1", "user_id": sess.AccessToken.AdditionalData["user_nsid"], }, sess.AccessToken) if err != nil { return nil, err } defer response.Body.Close() bits, err := ioutil.ReadAll(response.Body) err = json.NewDecoder(bytes.NewReader(bits)).Decode(&user.RawData) if err != nil { return nil, err } user.AccessToken = sess.AccessToken.Token user.AccessTokenSecret = sess.AccessToken.Secret err = userFromReader(bytes.NewReader(bits), &user) return &user, err }
// FetchUser will go to Tumblr and access basic information about the user. func (p *Provider) FetchUser(session goth.Session) (*goth.User, error) { user := goth.User{} sess := session.(*Session) response, err := p.consumer.Get( endpointProfile, map[string]string{}, sess.AccessToken) if err != nil { return nil, err } defer response.Body.Close() bits, err := ioutil.ReadAll(response.Body) err = json.NewDecoder(bytes.NewReader(bits)).Decode(&user.RawData) if err != nil { return nil, err } user.AccessToken = sess.AccessToken.Token user.AccessTokenSecret = sess.AccessToken.Secret err = userFromReader(bytes.NewReader(bits), &user) return &user, err }