nuxt-community / auth-module

Zero-boilerplate authentication support for Nuxt 2
https://auth.nuxtjs.org
MIT License
1.93k stars 925 forks source link

Token request on authorization_code flow sent with wrong content-type #1716

Open flyte opened 2 years ago

flyte commented 2 years ago

Version

module: 5.0.0-1648802546.c9880dc
nuxt: 2.15.8

Nuxt configuration

mode:

Nuxt configuration

  auth: {
    redirect: {
      callback: "/oauth2/callback",
    },
    strategies: {
      oidc: {
        scheme: "openIDConnect",
        clientId: 'REDACTED',
        endpoints: {
          configuration: '<REDACTED>/.well-known/openid-configuration',
        },
        scope: ['openid', 'email', 'profile', 'address', 'phone'],
        responseType: 'code',
        grantType: 'authorization_code',
        redirectUri: 'https://localhost:3000/oauth2/callback',
        logoutRedirectUri: '/',
        codeChallengeMethod: 'S256',
      },
    },
  },

-->

Reproduction

Trigger login with $nuxt.$auth.login() and then be redirected back to callback, which then tries to swap the authorization code for the tokens.

What is expected?

The authorization code is sent to the /token endpoint with a content-type of application/x-www-form-urlencoded.

What is actually happening?

It's being sent with a content-type of application/json, but the actual body is urlencoded, not JSON.

Steps to reproduce

Additional information

I believe this is happening here (no content-type is being set) https://github.com/nuxt-community/auth-module/blob/dev/src/schemes/oauth2.ts#L390

Whereas here, it is: https://github.com/nuxt-community/auth-module/blob/dev/src/schemes/oauth2.ts#L455

Checklist