adonisjs / ally

AdonisJS Social Authentication Provider
MIT License
158 stars 54 forks source link

Missing scope in Discord OAuth2 #127

Closed Bricklou closed 3 years ago

Bricklou commented 3 years ago

Package version

^4.1.0

Node.js and npm version

NodeJS 16.6.1 NPM 7.20.5

Sample Code (to reproduce the issue)

Discord authentication need the identify scope to work properly, on the other hand, the email scope is optional: https://github.com/adonisjs/ally/blob/3400eb99c9889a6a843f8058b0a07150d99734f8/src/Drivers/Discord/index.ts#L80 The documentation about the user fetch: https://discord.com/developers/docs/resources/user#get-current-user

Here what I had to do to fix temporarily my code:

const allyConfig: AllyConfig = {
  /*
    |--------------------------------------------------------------------------
    | Discord driver
    |--------------------------------------------------------------------------
    */
  discord: {
    driver: 'discord',
    clientId: Env.get('DISCORD_CLIENT_ID'),
    clientSecret: Env.get('DISCORD_CLIENT_SECRET'),
    callbackUrl: Env.get('DISCORD_REDIRECT_URI'),
    scopes: ['identify', 'email'],
  },
}

https://github.com/Bricklou/supportlauncher-market/blob/1f53017fc238bdf218ceb2308235da860b616a35/config/ally.ts#L20-L33

RomainLanz commented 3 years ago

Hey @Bricklou! 👋

Would you mind sending a PR?

Bricklou commented 3 years ago

Yes, no problem