You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-11-29 22:48:19 +02:00
linkedidn: Update provider to v2 (#1315)
* linkedin: Update provider to v2 * changelog: Add change
This commit is contained in:
committed by
GitHub
parent
3957183fd5
commit
fd5e23e1c5
@@ -19,7 +19,7 @@ var _ Provider = (*LinkedInProvider)(nil)
|
||||
|
||||
const (
|
||||
linkedinProviderName = "LinkedIn"
|
||||
linkedinDefaultScope = "r_emailaddress r_basicprofile"
|
||||
linkedinDefaultScope = "r_emailaddress r_liteprofile"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -28,7 +28,7 @@ var (
|
||||
linkedinDefaultLoginURL = &url.URL{
|
||||
Scheme: "https",
|
||||
Host: "www.linkedin.com",
|
||||
Path: "/uas/oauth2/authorization",
|
||||
Path: "/oauth/v2/authorization",
|
||||
}
|
||||
|
||||
// Default Redeem URL for LinkedIn.
|
||||
@@ -43,8 +43,8 @@ var (
|
||||
// Pre-parsed URL of https://www.linkedin.com/v1/people/~/email-address.
|
||||
linkedinDefaultProfileURL = &url.URL{
|
||||
Scheme: "https",
|
||||
Host: "www.linkedin.com",
|
||||
Path: "/v1/people/~/email-address",
|
||||
Host: "api.linkedin.com",
|
||||
Path: "/v2/emailAddress",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -76,7 +76,7 @@ func (p *LinkedInProvider) GetEmailAddress(ctx context.Context, s *sessions.Sess
|
||||
return "", errors.New("missing access token")
|
||||
}
|
||||
|
||||
requestURL := p.ProfileURL.String() + "?format=json"
|
||||
requestURL := p.ProfileURL.String() + "?q=members&projection=(elements*(handle~))"
|
||||
json, err := requests.New(requestURL).
|
||||
WithContext(ctx).
|
||||
WithHeaders(makeLinkedInHeader(s.AccessToken)).
|
||||
@@ -85,8 +85,7 @@ func (p *LinkedInProvider) GetEmailAddress(ctx context.Context, s *sessions.Sess
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
email, err := json.String()
|
||||
email, err := json.Get("elements").GetIndex(0).Get("handle~").Get("emailAddress").String()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user