nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
23.88k stars 3.29k forks source link

Undocumented Changes to provider fields #10857

Open Nik-Novak opened 3 months ago

Nik-Novak commented 3 months ago

Provider type

Custom provider, Twitch

Environment

System:
    OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 9 5950X 16-Core Processor
    Memory: 3.04 GB / 15.75 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 20.12.0 - ~/.nvm/versions/node/v20.12.0/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.12.0/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.0/bin/npm
  npmPackages:
    @auth/prisma-adapter: ^1.5.1 => 1.5.1 
    next: ^14.2.3 => 14.2.3 
    next-auth: ^5.0.0-beta.17 => 5.0.0-beta.17 
    react: ^18.3.1 => 18.3.1

Reproduction URL

https://github.com/Nik-Novak/Mind-Knight

Describe the issue

token: {
      async request() {
        console.log('RUN token');
        if (!req.url) {
          throw new Error('No URL found in request object')
        }

        const identifier = await verifyAssertion(req, realm, returnTo)

        if (!identifier) {
          throw new Error('Unauthenticated')
        }

        return {
          tokens: new TokenSet({
            id_token: randomUUID(),
            access_token: randomUUID(),
            steamId: identifier
          })
        }
      }
    },

    userinfo: {
      async request(ctx) {
        console.log('RUN userinfo.request');
        const url = new URL('https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002')

        url.searchParams.set('key', ctx.provider.clientSecret as string)
        url.searchParams.set('steamids', ctx.tokens.steamId as string)

        const response = await fetch(url)
        const data = await response.json()
        console.log('PROFILE',data.response.players[0] );
        return data.response.players[0]
      }
    },

In V5, this no longer works and causes all kinds of errors. Can this be resolved or can we get some documentation on the changes?

How to reproduce

Try to migrate this to V5: https://pastebin.com/rDH6GZ1a

(was working fine in V4)

Expected behavior

.

bernsteinmatt commented 2 months ago

Has there been a solution for this? I'm running into the same issue