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

User avatar is given in "avatarUrl" instead of "photos" #12

Open
andyli opened this issue May 20, 2019 · 1 comment
Open

User avatar is given in "avatarUrl" instead of "photos" #12

andyli opened this issue May 20, 2019 · 1 comment

Comments

@andyli
Copy link

andyli commented May 20, 2019

Unlike several other passport strategies (including passport-facebook, passport-github, and passport-twitter) that provide the user avatar in the profile object photos field, passport-gitlab2 uses avatarUrl instead.

Is there any reason for that? Would you accept a PR that change it?

@zamrokk
Copy link

zamrokk commented Jul 3, 2023

I agree with previous post. Having the field with different name cause me troubles on NestJs AuthGuard validate function, I can extract it based on your naming, but If I try later to fetch it from the Request callback function, it has disappeared :'(

async validate(
    _accessToken: string,
    _refreshToken: string,
    profile: Profile & { avatar_url: string },
  ) {
    Logger.debug('GOOGLE', profile);

    const { avatar_url, provider, displayName, username } = profile;

    console.log('PROFILE', profile);

    return {
      accessToken: _accessToken,
      provider: provider,
      providerId: username,
      name: displayName,
      username: username,
      photo: avatar_url,
    };
  }

Here , req.user.photo is empty ...

@UseGuards(AuthGuard('gitlab'))
@Get('callback')
async GitlabCallback(@Req() req: any, @Res() res: express.Response) {
  const gitlabAccessToken = req.user.accessToken;

  Logger.debug(
    'Gitlab callback received user with GitlabAccessToken',
    gitlabAccessToken,
    req.user,
  );

  this.siwtService.gitlabPending.set(
    gitlabAccessToken,
    new UserProfile(
      gitlabAccessToken,
      req.user.name,
      req.user.provider,
      req.user.username,
      req.user.photo,
    ),
  );
  ```

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