0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

NextAuth v5でDiscordのOAuth2.0のスコープを指定するのに手こずった

Posted at

NextAuth5で翻弄したので備忘録。
Discord({authorization:{ params: ... }}) とかネットには書いてあったけど、できない。

権限を追加するには?

結論として、普通に時前で作ればいいだけでした。

const makeDiscordAuthURL=(...args:string[])=>`https://discord.com/api/oauth2/authorize?scope=${args.join('+')}`

// Usage:
export const auther = NextAuth({
  providers: [
    Discord({
      clientId: /* ... */,
      clientSecret: /* ... */,
      authorization: makeDiscordAuthURL('identify', 'email', 'guilds')
    })
  ],
  // ...
})

取得するなら

ちなみに、アダプタを使ってないなら基本的にトークンはcallbacks内でしか操れないらしい。

もしトークンを使ってユーザーの情報を取得するなら↓

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?