kinde-oss / kinde-auth-nextjs

Kinde NextJS SDK - authentication for server rendered apps
https://kinde.com/docs/developer-tools/nextjs-sdk/
MIT License
132 stars 17 forks source link

Bug: Error: Cannot get user details, no authentication credential found #150

Closed Thinkscape closed 1 month ago

Thinkscape commented 2 months ago

Prerequisites

Describe the issue

"use client";
import { useKindeBrowserClient } from "@kinde-oss/kinde-auth-nextjs";

export function Page() {
  const {
    isLoading,
    isAuthenticated,
  } = useKindeBrowserClient();

  return <div>{isAuthenticated}</div>
}

Every time the component is rendered, and the user is not currently logged in, it spams this error into our platform error logs:

Error: Cannot get user details, no authentication credential found
    at eval (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-typescript-sdk/dist/sdk/clients/server/authorization-code.js:166:31)
    at step (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-typescript-sdk/dist/sdk/clients/server/authorization-code.js:50:23)
    at Object.eval [as next] (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-typescript-sdk/dist/sdk/clients/server/authorization-code.js:31:53)
    at fulfilled (webpack-internal:///(rsc)/./node_modules/@kinde-oss/kinde-typescript-sdk/dist/sdk/clients/server/authorization-code.js:22:58)

Library URL

https://github.com/kinde-oss/kinde-auth-nextjs

Library version

2.2.3

Operating system(s)

macOS

Operating system version(s)

n/a

Further environment details

Next.js 14.2.2

Reproducible test case URL

No response

Additional information

No response

peterphanouvong commented 2 months ago

Thank you for raising, we will put the logs behind an env variable KINDE_DEBUG_MODE=true in the next release

Thinkscape commented 2 months ago

Thank you for raising, we will put the logs behind an env variable KINDE_DEBUG_MODE=true in the next release

Consider a more future-proof config var, like KINDE_LOG_LEVEL. The above seems to be something that would live in debug level, but there might be useful warnings, that are not errors, in the future.

DanielRivers commented 1 month ago

Hi, The immediate problem of the error "Error: Cannot get user details, no authentication credential found" has been resolved.

will close this issue, you have a valid suggestion with the log level, will look at this in future releases.