instructure / canvas-lms

The open LMS by Instructure, Inc.
https://github.com/instructure/canvas-lms/wiki
GNU Affero General Public License v3.0
5.41k stars 2.42k forks source link

NextAuth saying token_endpoint must be configured by issuer (Canvas) #2318

Open thereallogani opened 4 months ago

thereallogani commented 4 months ago

Summary: NextAuth provider is failing to work with Canvas. This error leads me to believe there is some token_endpoint not supported on the canvas side. I'm not an OAuth expert, but this seems to be part of the spec that doesn't exist?

Steps to reproduce:

  1. Set up NextAuth customer provider: https://next-auth.js.org/v3/configuration/providers#using-a-custom-provider for Canvas
  2. Try to use provider to authenticate a third party app using canvas

Expected behavior:

Login successful

Actual behavior:

Seeing this log from NextAuth:

[next-auth][debug][GET_AUTHORIZATION_URL] { url: 'http://assignguard.instructure.com/login/oauth2/auth?client_id=237180000000000002&scope=openid&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fcallback%2Fcanvas&state=ZQrEcgBDaeQs1iom7sOWFex726-0AdfK-Vj48yb8dp8', cookies: [ { name: 'next-auth.state', value: '<STATE>', options: [Object] } ], provider: { id: 'canvas', name: 'Canvas', type: 'oauth', version: '2.0', scope: 'https://assignguard.instructure.com/login/oauth2/userinfo.profile', params: { grant_type: 'authorization_code' }, accessTokenUrl: 'https://assignguard.instructure.com/login/oauth2/token', requestTokenUrl: 'https://assignguard.instructure.com/login/oauth2/auth', jwks_endpoint: 'https://assignguard.instructure.com/api/lti/developer_key/update_public_jwk', authorization: { url: 'https://assignguard.instructure.com/login/oauth2/auth', params: [Object] }, profileUrl: 'https://assignguard.instructure.com/login/oauth2/v2/userinfo?alt=json', profile: [AsyncFunction: profile], clientId: '<CLIENT_ID>', clientSecret: '<CLIENT_SECRET>', idToken: false, checks: [ 'state' ], signinUrl: 'http://localhost:3000/api/auth/signin/canvas', callbackUrl: 'http://localhost:3000/api/auth/callback/canvas' } } [next-auth][error][OAUTH_CALLBACK_ERROR] https://next-auth.js.org/errors#oauth_callback_error token_endpoint must be configured on the issuer { error: TypeError: token_endpoint must be configured on the issuer at assertIssuerConfiguration (webpack-internal:///(rsc)/./node_modules/openid-client/lib/helpers/assert.js:13:15) at Client.grant (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:1197:9) at Client.oauthCallback (webpack-internal:///(rsc)/./node_modules/openid-client/lib/client.js:533:41) at oAuthCallback (webpack-internal:///(rsc)/./node_modules/next-auth/core/lib/oauth/callback.js:120:35) at async Object.callback (webpack-internal:///(rsc)/./node_modules/next-auth/core/routes/callback.js:18:79) at async AuthHandler (webpack-internal:///(rsc)/./node_modules/next-auth/core/index.js:202:38) at async NextAuthRouteHandler (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:50:30) at async NextAuth._args$ (webpack-internal:///(rsc)/./node_modules/next-auth/next/index.js:85:24) at async /Users/loganohara/code/instructify/assignguard/src/web/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62499 { name: 'OAuthCallbackError', code: undefined }, providerId: 'canvas', message: 'token_endpoint must be configured on the issuer' }

Additional notes: