Issue with logging into Sanity Studio due to browser cookie error.
18 replies
Last updated: Feb 17, 2022
T
So a while back I had transferred ownership of my project from a Sanity account that was created with a GitHub login to one that was created directly with Sanity using an email address -- I had run into issues using login providers elsewhere and decided to stop using them across the board.
So I created a throwaway email, used that to create a Sanity organization, transferred the project to that, deleted the old Sanity account, created a new one using the same email just without the GitHub provider, added that user as an admin on the new org, and deleted the throwaway account. Everything looked good -- I did some front end work on the project and I've been able to deploy that using Netlify. I even updated sanity and built and deployed it.
But I didn't actually try to use Sanity Studio to edit content. This is a little personal blog project that I rarely actually update. So today I tried to log in and am getting "unknown user" errors, both locally and on the
_.sanity.studio URL. I can't find anywhere that stores user credentials -- no cookies, local storage, .env files, etc. All I can find is a 404 error for this URL in the console:
https://covwi5zn.api.sanity.io/v2021-06-07/users/me?tag=sanity.studio.users.get-current
Any ideas how to resolve this?
So I created a throwaway email, used that to create a Sanity organization, transferred the project to that, deleted the old Sanity account, created a new one using the same email just without the GitHub provider, added that user as an admin on the new org, and deleted the throwaway account. Everything looked good -- I did some front end work on the project and I've been able to deploy that using Netlify. I even updated sanity and built and deployed it.
But I didn't actually try to use Sanity Studio to edit content. This is a little personal blog project that I rarely actually update. So today I tried to log in and am getting "unknown user" errors, both locally and on the
_.sanity.studio URL. I can't find anywhere that stores user credentials -- no cookies, local storage, .env files, etc. All I can find is a 404 error for this URL in the console:
https://covwi5zn.api.sanity.io/v2021-06-07/users/me?tag=sanity.studio.users.get-current
Any ideas how to resolve this?
Feb 11, 2022, 3:19 PM
A
Hi User. Are you able to sign into Manage ? If so, please could check whether
covwi5znis the correct id for your project?
Feb 11, 2022, 3:25 PM
T
Yes I'm able to log in there, and that's the right ID. This is my sanity.json from the studio project:
{ "root": true, "project": { "name": "tcblog" }, "api": { "projectId": "covwi5zn", "dataset": "production" }, "plugins": [ "@sanity/base", "@sanity/components", "@sanity/default-layout", "@sanity/default-login", "@sanity/desk-tool" ], "env": { "development": { "plugins": [ "@sanity/vision" ] } }, "parts": [ { "name": "part:@sanity/base/schema", "path": "./schemas/schema.js" } ] }
Feb 11, 2022, 3:28 PM
T
And this is the URL for the project's page in Sanity studio -- shows the ID there too:
https://www.sanity.io/organizations/oCrgdkmXp/project/covwi5zn
https://www.sanity.io/organizations/oCrgdkmXp/project/covwi5zn
Feb 11, 2022, 3:30 PM
A
Thanks for checking that. Please can I ask you to visit this URL in the same browser you are using for Sanity Studio, and DM me the response body.
Feb 11, 2022, 3:33 PM
T
Done. I'm guessing this is somehow tied to the fact that the new account uses the same email as the old GitHub login provider account.
Feb 11, 2022, 3:39 PM
A
I think there's definitely some kind of mix up. I can see the admin user of your project has a different id to the id you are currently authenticated as.
Just to double check; when you signed in, did you select the "E-mail / password" option?
Just to double check; when you signed in, did you select the "E-mail / password" option?
Feb 11, 2022, 3:45 PM
T
In the Manage area, yes I get a prompt and choose Email/password".
When trying to use the studio I don't even get the option to log in, it just goes straight to the "user unknown" error. That's why I thought there must be a cookie or something, but I cleared everything, tried incognito, etc.
When trying to use the studio I don't even get the option to log in, it just goes straight to the "user unknown" error. That's why I thought there must be a cookie or something, but I cleared everything, tried incognito, etc.
Feb 11, 2022, 3:51 PM
T
Ah wait, I can log in in a different browser (I was using Chrome, but it works in Firefox). Still doesn't prompt me to login though.
And I just noticed that in Chrome incognito I get an error about cookies. It says "WE COULDN'T LOG YOU IN
Your browser wouldn't accept our cookie." And there is a "TRY AGAIN" button. If I click that it opens a popup, it says "*Your browser wouldn't accept our cookie*
Press the button below to try to resolve the problem." and there's a CONTNUE button, I click that and it says "*Thanks, that should do it!*
If you still have problems, make sure your browser doesn't block all third party cookies, or try another browser."
And I just noticed that in Chrome incognito I get an error about cookies. It says "WE COULDN'T LOG YOU IN
Your browser wouldn't accept our cookie." And there is a "TRY AGAIN" button. If I click that it opens a popup, it says "*Your browser wouldn't accept our cookie*
Press the button below to try to resolve the problem." and there's a CONTNUE button, I click that and it says "*Thanks, that should do it!*
If you still have problems, make sure your browser doesn't block all third party cookies, or try another browser."
Feb 11, 2022, 3:54 PM
T
Ah wait, I can log in in a different browser (I was using Chrome, but it works in Firefox). Still doesn't prompt me to login though.
And I just noticed that in Chrome incognito I get an error about cookies. It says "WE COULDN'T LOG YOU IN
Your browser wouldn't accept our cookie." And there is a "TRY AGAIN" button. If I click that it opens a popup, it says "*Your browser wouldn't accept our cookie*
Press the button below to try to resolve the problem." and there's a CONTNUE button, I click that and it says "*Thanks, that should do it!*
If you still have problems, make sure your browser doesn't block all third party cookies, or try another browser."
And I just noticed that in Chrome incognito I get an error about cookies. It says "WE COULDN'T LOG YOU IN
Your browser wouldn't accept our cookie." And there is a "TRY AGAIN" button. If I click that it opens a popup, it says "*Your browser wouldn't accept our cookie*
Press the button below to try to resolve the problem." and there's a CONTNUE button, I click that and it says "*Thanks, that should do it!*
If you still have problems, make sure your browser doesn't block all third party cookies, or try another browser."
Feb 11, 2022, 3:54 PM
T
I guess that
Feb 11, 2022, 3:56 PM
T
I guess that
Feb 11, 2022, 3:56 PM
T
I guess that's because it's incognito. Still doesn't explain why even after clearing all cookies, local storage, etc. the main non-incognito window doesn't work. It's like something from an old login session is stuck somewhere in the browser.
Feb 11, 2022, 3:57 PM
A
The cookie error is unfortunately a known issue. We're working to provided a fix as soon as we can. It occurs when the web browser declines third-party cookies for one reason or another... understandably, this mode is the default for a lot of folks today!
Feb 11, 2022, 3:59 PM
A
The Chrome issue is certainly strange! After you have cleared all of your saved browser data, what do you get back from this URL ?
Feb 16, 2022, 11:20 AM
T
So I managed to get it working. I had to use Chrome's settings to search all saved browser data and deleted anything mentioning "sanity". Unfortunately I don't know what specifically fixed it, but it was some saved data that wasn't showing up in the dev tools either on my local dev instance or in the Sanity-hosted studio. I guess it is probably a 3rd party cookie but I thought those showed in the dev tools.
But to answer your question, I get an empty object at that URL:
But to answer your question, I get an empty object at that URL:
Feb 16, 2022, 4:15 PM
T
So I managed to get it working. I had to use Chrome's settings to search all saved browser data and deleted anything mentioning "sanity". Unfortunately I don't know what specifically fixed it, but it was some saved data that wasn't showing up in the dev tools either on my local dev instance or in the Sanity-hosted studio. I guess it is probably a 3rd party cookie but I thought those showed in the dev tools.
But to answer your question, I get an empty object at that URL:
But to answer your question, I get an empty object at that URL:
Feb 16, 2022, 4:15 PM
A
I'm glad that addressed the issue! I'll keep an eye out for anything similar happening in Chrome; it'd be interesting to know which data it had squirrelled away.
Thank you for sharing the response you get. An empty object should mean you are signed out.
Thank you for sharing the response you get. An empty object should mean you are signed out.
Feb 17, 2022, 9:28 AM
A
I'm glad that addressed the issue! I'll keep an eye out for anything similar happening in Chrome; it'd be interesting to know which data it had squirrelled away.
Thank you for sharing the response you get. An empty object should mean you are signed out.
Thank you for sharing the response you get. An empty object should mean you are signed out.
Feb 17, 2022, 9:28 AM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.