While trying to navigate the documentation for Next Auth, I found myself struggling with outdated examples and an overall lack of clarity. It appears that the documentation is still a work in progress, making it challenging to find reliable information on how to effectively implement this authentication system. Despite investing hours into watching video tutorials and reading related articles, I constantly encounter outdated information due to the rapid pace at which things change.
My attempt to adapt the authentication system from the official Next.js website tutorial resulted in errors, such as the following:
Upon checking the VSCode frontend console, I encountered errors like:
Response from API: {
user: { id: 4, username: 'bob', email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73011c171c031a42...>' },
refresh: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
access: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
}
[auth][error] CallbackRouteError: Read more at https://errors.authjs.dev#callbackrouteerror
[auth][cause]: TypeError: "ikm"" must be an instance of Uint8Array or a string
............
[auth][details]: {
"provider": "credentials"
}
Authentication Error: CallbackRouteError: Read more at https://errors.authjs.dev#callbackrouteerror
at Module.callback (webpack-internal:///(action-browser)/./node_modules/@auth/core/lib/actions/callback/index.js:437:23)
....................
type: 'CallbackRouteError',
kind: 'error',
[cause]: {
err: TypeError: "ikm"" must be an instance of Uint8Array or a string
I would greatly appreciate any guidance or assistance in resolving these issues.
For context, my backend is built on Django and DRF, utilizing JWT Simple, although specifics may not be crucial. The backend creates endpoints:
127.0.0.1:8000/auth/login/
127.0.0.1:8000/auth/register/
127.0.0.1:8000/auth/refresh/token
These endpoints have been verified to function correctly using Postman. In the frontend, specifically within Next.js v14:
In the project root, I have an auth.config.ts file containing the following code:
(Code snippet provided, please refer to original text for full detail)
(Additional content omitted for brevity)