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

[Feature request] Extract profile common fields #181

Open
tiaod opened this issue Jul 20, 2020 · 1 comment
Open

[Feature request] Extract profile common fields #181

tiaod opened this issue Jul 20, 2020 · 1 comment

Comments

@tiaod
Copy link
Contributor

tiaod commented Jul 20, 2020

In the current version, the profile returns the original data

Developers need to write a logic for each provider to extract general information such as username, avatar, id, email, etc.

// Every developer has to write similar code:
let userInfo = {}
switch (grant.provider){
  case 'github':
    userInfo.id = profile.id
    userInfo.avater = profile.avatar_url
    userInfo.nickname = profile.name
    userInfo.email = profile.email
    break
  case 'weibo':
    userInfo.id = profile.id
    userInfo.avatar = profile.profile_image_url
    userInfo.nickname = profile.name
    userInfo.email = profile.email
    break
  case 'qq':
    userInfo.id = profile.openid
    userInfo.avatar = profile.figureurl_2,
    userInfo.nickname = profile.nickname
    break
}

So maybe it's better to let grant extract these common fields and keep the original data to profile.raw

{
  access_token: '...',
  refresh_token: '...',
  profile: {
    id: '123',
    avatar: 'https://.....',
    nickname: 'tiaod',
    email: 'example@example.com',
    raw: {
      ... //the raw profile data
    }
  }
}
@simov
Copy link
Owner

simov commented Jul 20, 2020

That's a good idea, but definitely not a priority.

Having all profile URLs set and tested for all providers, plus any potential fix needed for the underlying HTTP client is a good step forward.

Also keep in mind that we're talking about 180+ providers, and for an endpoint that's largely not standardized, besides the OpenID Connect userinfo one. One thing is to support multiple OAuth implementations that might differ a little, another is to support basically a random endpoint.

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

No branches or pull requests

2 participants