func (p *MyUsaProvider) GetEmailAddress(body []byte, access_token string) (string, error) { req, err := http.NewRequest("GET", p.ProfileUrl.String()+"?access_token="+access_token, nil) if err != nil { log.Printf("failed building request %s", err) return "", err } json, err := api.Request(req) if err != nil { log.Printf("failed making request %s", err) return "", err } return json.Get("email").String() }
func (p *MyUsaProvider) GetEmailAddress(s *SessionState) (string, error) { req, err := http.NewRequest("GET", p.ProfileURL.String()+"?access_token="+s.AccessToken, nil) if err != nil { log.Printf("failed building request %s", err) return "", err } json, err := api.Request(req) if err != nil { log.Printf("failed making request %s", err) return "", err } return json.Get("email").String() }
func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) { if s.AccessToken == "" { return "", errors.New("missing access token") } req, err := http.NewRequest("GET", p.ProfileURL.String(), nil) if err != nil { return "", err } req.Header = getAzureHeader(s.AccessToken) json, err := api.Request(req) if err != nil { log.Printf("failed making request %s", err) return "", err } return json.Get("mail").String() }
func (p *LinkedInProvider) GetEmailAddress(s *SessionState) (string, error) { if s.AccessToken == "" { return "", errors.New("missing access token") } req, err := http.NewRequest("GET", p.ProfileUrl.String()+"?format=json", nil) if err != nil { return "", err } req.Header = getLinkedInHeader(s.AccessToken) json, err := api.Request(req) if err != nil { return "", err } email, err := json.String() if err != nil { return "", err } return email, nil }
func (p *AzureProvider) GetEmailAddress(s *SessionState) (string, error) { var email string var err error if s.AccessToken == "" { return "", errors.New("missing access token") } req, err := http.NewRequest("GET", p.ProfileURL.String(), nil) if err != nil { return "", err } req.Header = getAzureHeader(s.AccessToken) json, err := api.Request(req) if err != nil { return "", err } email, err = getEmailFromJSON(json) if err == nil && email != "" { return email, err } email, err = json.Get("userPrincipalName").String() if err != nil { log.Printf("failed making request %s", err) return "", err } if email == "" { log.Printf("failed to get email address") return "", err } return email, err }
func (p *LinkedInProvider) GetEmailAddress(body []byte, access_token string) (string, error) { if access_token == "" { return "", errors.New("missing access token") } params := url.Values{} req, err := http.NewRequest("GET", p.ProfileUrl.String()+"?format=json", bytes.NewBufferString(params.Encode())) if err != nil { return "", err } req.Header = getLinkedInHeader(access_token) json, err := api.Request(req) if err != nil { log.Printf("failed making request %s", err) return "", err } email, err := json.String() if err != nil { log.Printf("failed making request %s", err) return "", err } return email, nil }