Next-auth: Access_token in profileUrl?

Created on 23 Jun 2020  路  8Comments  路  Source: nextauthjs/next-auth

Hi! I'm trying to make an authentication via mail.ru. According to the documentation, it is necessary to include access_token into the request for user information. Is it possible to addaccess_tokento profileUrl like this https://oauth.mail.ru/userinfo?access_token=8e41b7a475aa7691aeead06ef0db28f989fbab0c37363830?

question

All 8 comments

The access token is automatically added to the profileUrl. So it should work without it.

But metadata shows:

{
  error: 'invalid request',
  error_code: 2,
  error_description: 'missing request parameter: access_token'
}

Hmm, can you share your provider details? (minus Client ID/Secret)?

Maybe we need to do something special for this provider - a small number of providers have uncommon implementations and require specific hacks to support (e.g. Okta, Twitch).

export default (options) => {
  return {
    id: 'mailru',
    name: 'Mail.ru',
    type: 'oauth',
    version: '2.0',
    scope: 'userinfo',
    params: { grant_type: 'authorization_code' },
    accessTokenUrl: 'https://oauth.mail.ru/token',
    requestTokenUrl: 'https://oauth.mail.ru/token',
    authorizationUrl: 'https://oauth.mail.ru/login?response_type=code',
    profileUrl: 'https://oauth.mail.ru/userinfo',
    profile: (profile) => {
      return {
        id: profile.id,
        name: profile.name,
        email: profile.email,
        image: profile.image,
      };
    },
    ...options,
  };
};

Error:
image

Thanks! Will take a look later.

522 adds support for Mail.ru as custom OAuth Service Provider.

Also, built-in support for Mail.ru has been added.

Closing this issue as the PR is basically completed and the discussion as moved there (https://github.com/nextauthjs/next-auth/pull/522)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bscaspar picture bscaspar  路  3Comments

ghoshnirmalya picture ghoshnirmalya  路  3Comments

iaincollins picture iaincollins  路  3Comments

readywater picture readywater  路  3Comments

iaincollins picture iaincollins  路  3Comments