Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkedin scopes updated to 'profile' and 'email' according to update … #581

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Rushikesh7888
Copy link

This pull request updates the LinkedIn OAuth scopes in the goth package to align with LinkedIn’s latest API requirements. LinkedIn has deprecated the previous scopes r_liteprofile and r_emailAddress and replaced them with profile and email. This change is essential to ensure that LinkedIn authentication continues to work as expected without encountering permission errors.

Changes Made:

Updated LinkedIn OAuth scopes in the relevant files from:

  • r_liteprofile ➔ profile
  • r_emailAddress ➔ email

Reason for Change: LinkedIn recently changed its API scope requirements, making r_liteprofile and r_emailAddress obsolete. Using the new scopes profile and email ensures compatibility with LinkedIn's API and allows applications to retrieve the necessary profile and email information without issues.

@chriscow
Copy link

@Rushikesh7888 - I was curious, did you try this? I think you have to update the fetch user endpoint as well and parse the userInfo differently from the OID response. Also the email comes along so we no longer need a separate request for that:

const (
    userEndpoint string = "//api.linkedin.com/v2/userinfo"
)


func userFromReader(reader io.Reader, user *goth.User) error {
	u := struct {
		Sub        string `json:"sub"`
		Name       string `json:"name"`
		GivenName  string `json:"given_name"`
		FamilyName string `json:"family_name"`
		Picture    string `json:"picture"`
		Locale     struct {
			Language string `json:"language"`
			Country  string `json:"country"`
		} `json:"locale"`
		Email         string `json:"email"`
		EmailVerified bool   `json:"email_verified"`
	}{}

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

	// Populate the goth.User fields
	user.UserID = u.Sub
	user.FirstName = u.GivenName
	user.LastName = u.FamilyName
	user.Name = u.Name
	user.NickName = u.GivenName
	user.AvatarURL = u.Picture
	user.Email = u.Email

	// Optionally, use locale data if needed
	// user.Locale = fmt.Sprintf("%s-%s", u.Locale.Language, u.Locale.Country)

	return nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants