[error] Prismic authentication state is invalid

Wasn't able to find anything around this error. Hope someone could help me out.

I've got a Next.js 13 instance running in Node v19.7.0.
When I tried npx @slicemachine/init in the directory, I got the following error:

Slice Machine  → Init command started
ℹ We collect telemetry data to improve user experience.
  Learn more: https://prismic.dev/slice-machine/telemetry
✔ Detected framework Next.js 11-13 and package manager npm
✔ Began core dependencies installation with npm ... (running in background)
✖ Logging in to Prismic...
  → Prismic authentication state is invalid.
UnexpectedDataError: Prismic authentication state is invalid.
    at PrismicAuthManager._readPersistedAuthState (/Users/x/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/auth/PrismicAuthManager.cjs:262:13)
    at async PrismicAuthManager.checkIsLoggedIn (/Users/x/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/manager/dist/auth/PrismicAuthManager.cjs:160:23)
    at async Task.task (/Users/x/.npm/_npx/b6923b01b288b666/node_modules/@slicemachine/init/dist/SliceMachineInitProcess.cjs:221:30)

I've tried Prismic Logout & Login, Reinstalling Prismic-cli, or manually installing slice-machine, it keeps throwing the same error. Has anyone run into the same problem?

Appreciate any help!!

Hi @motmotstudiostudio,

Thanks for your patience.

I reproduced the issue when I deleted the cookies attribute in the ~/.prismic file. I suggest you delete the ~/.prismic file and ran this command npx @slicemachine/init@latest

Let me know if this works for you.

Thanks,
Racheal.

1 Like

Hi Racheal,

I've got the same error but I have it when I run the command npx @slicemachine/init@latest

To giva a little more context :
I am trying to start a new project with Prismic, I tried starting from a full website demo prismic.io and starting from scratch Install Prismic with Nuxt 3 - Documentation - Prismic

I had this error when starting from scratch.
When I started from a template I couldn't access my repository having this error :

I also had this error on my terminal :

MBP-de-Giard:bleupale giardmathieu$ npm run dev

> nuxt-starter-prismic-multi-page@0.0.0 dev
> concurrently "npm:nuxt:dev" "npm:slicemachine" --names "nuxt,slicemachine" --prefix-colors green,magenta

[slicemachine] 
[slicemachine] > nuxt-starter-prismic-multi-page@0.0.0 slicemachine
[slicemachine] > start-slicemachine
[slicemachine] 
[nuxt] 
[nuxt] > nuxt-starter-prismic-multi-page@0.0.0 nuxt:dev
[nuxt] > nuxt dev
[nuxt] 
[nuxt] Nuxt 3.8.0 with Nitro 2.7.0
[nuxt] 
[nuxt]   ➜ Local:    http://localhost:3000/
[nuxt]   ➜ Network:  use --host to expose
[nuxt] 
[slicemachine] 
[slicemachine]  Slice Machine v1.23.0  → Running at http://localhost:9999
[slicemachine] 
[slicemachine] This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
[slicemachine] SMUnexpectedDataError: Prismic authentication state is invalid.
[slicemachine]     at PrismicAuthManager._readPersistedAuthState (/Users/giardmathieu/Documents/Bleu_pale/bleupale/node_modules/@slicemachine/manager/dist/auth/PrismicAuthManager.cjs:268:13)
[slicemachine]     at async PrismicAuthManager.checkIsLoggedIn (/Users/giardmathieu/Documents/Bleu_pale/bleupale/node_modules/@slicemachine/manager/dist/auth/PrismicAuthManager.cjs:160:23)
[slicemachine]     at async StartSliceMachineProcess._fetchProfile (/Users/giardmathieu/Documents/Bleu_pale/bleupale/node_modules/start-slicemachine/dist/StartSliceMachineProcess.cjs:136:24)
[slicemachine]     at async StartSliceMachineProcess.run (/Users/giardmathieu/Documents/Bleu_pale/bleupale/node_modules/start-slicemachine/dist/StartSliceMachineProcess.cjs:76:21)
[nuxt] [nuxt:prismic] ℹ Using user-defined richTextSerializer at ~/app/prismic/richTextSerializer.ts
[nuxt] [nuxt:prismic] ℹ Using default preview page, available at /api/preview
[nuxt] [nuxt:tailwindcss] ℹ Using default Tailwind CSS file
[nuxt]   ➜ DevTools: press Shift + Option + D in the browser (v1.0.0)
[nuxt] 
[nuxt] [nuxt:tailwindcss] ℹ Tailwind Viewer: http://localhost:3000/_tailwind/
[nuxt] ℹ Vite client warmed up in 5163ms
[nuxt] [nitro] ✔ Nitro built in 2027 ms

Could you help ?

Thanks in advance,
Mathieu

Hi @mathieu.giard, could you delete your .prismic file in your home directory and try again? That file contains your authentication state, which appears to be corrupted for some reason.

You can delete it with the following command:

npx prismic-cli@latest logout