Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Issue with deployment and login loop due to lack of admin permission

10 replies
Last updated: Apr 15, 2021
Hey all, I have this really bizarre issue with deployment and login.I am stuck in a CLI loop – here’s what happens when I try to deploy:

$ sanity login
? Login type GitHub

Opening browser at <https://api.sanity.io/v1/auth/login/github?type=listen&uuid=5bdfec28f8357d0fef479bed44889d4c&source=cli>

Login successful
$ sanity deploy
✔ Checking project info
✔ Clearing output folder (6ms)
✔ Building Sanity (22224ms)
✔ Building index document (27ms)
✔ Minifying JavaScript bundles (20340ms)
✔ Verifying local content
✖ Deploying to Sanity.Studio
Error: You've been logged out. Log back in again with "sanity login"
    at onError (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1902:1974)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2820:241
    at Array.reduce (<anonymous>)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2820:225
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2808:965
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2808:1028
    at x (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2856:1442)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2856:2885
    at u.<anonymous> (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1554:181)
So I
1. login,
2. deploy,
3. deploy fails because i’m logged out
4. I log in again,
repeat.

What is happening here?
Apr 15, 2021, 8:18 PM
What happens if you run
sanity logout && sanity login
to reset things, then try another deploy?
Apr 15, 2021, 8:22 PM
same thing – of course it think’s I’m logged out anyway so it says No Login Credentials Found:
$ sanity logout && sanity login
No login credentials found
? Login type GitHub

Opening browser at <https://api.sanity.io/v1/auth/login/github?type=listen&uuid=b5b9c6c6aaefae9f7667538eeca63b63&source=cli>

Login successful
(base) Josephs-MBP-2:cms jiovino$ sanity deploy
✔ Checking project info
✔ Clearing output folder (6ms)
✔ Building Sanity (22094ms)
✔ Building index document (28ms)
✔ Minifying JavaScript bundles (20038ms)
✔ Verifying local content
✖ Deploying to Sanity.Studio
Error: You've been logged out. Log back in again with "sanity login"
    at onError (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1902:1974)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2820:241
    at Array.reduce (<anonymous>)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2820:225
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2808:965
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2808:1028
    at x (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2856:1442)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2856:2885
    at u.<anonymous> (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1554:181)
Apr 15, 2021, 8:24 PM
Any chance the terminal command
DEBUG=sanity* sanity deploy
returns anything useful?
Apr 15, 2021, 8:32 PM
Any chance
DEBUG=sanity* sanity deploy
returns anything useful?
Apr 15, 2021, 8:32 PM
Thanks again - it runs into the same issue –1. I login, successfully,
2. it goes partway through the Debug, and then throws the Error: You’ve been logged out.

Perhaps there’s something in these Debug results that could help?
Here’s what happens:

$ sanity login
? Login type GitHub

Opening browser at <https://api.sanity.io/v1/auth/login/github?type=listen&uuid=129e2140b0d883478ed652a14c064ef3&source=cli>

Login successful
(base) Josephs-MBP-2:cms jiovino$ DEBUG=sanity* sanity deploy
  sanity:cli CLI installed at /usr/local/lib/node_modules/@sanity/cli/bin +0ms
  sanity:cli Less than 12 hours since last check, skipping update check +11ms
  sanity:cli Less than 12 hours since last nag, skipping +1ms
  sanity:cli No group found with name "deploy", looking for command +455ms
  sanity:cli Found command in default group with name "deploy" +0ms
  sanity:cli Reading "/Users/jiovino/projects/humility-monolith/cms/sanity.json" +1ms
  sanity:cli Running command "deploy" +2ms
⠋ Checking project info  sanity:client [1] HTTP GET <https://1opf3ch9.api.sanity.io/v1/projects/1opf3ch9> +0ms
  sanity:client [1] Request headers: {
  "Accept": "application/json",
  "User-Agent": "@sanity/client 0.147.0",
  "Authorization": "<redacted>"
} +1ms
⠹ Checking project info  sanity:client [1] Response code: 200 OK +216ms
  sanity:client [1] Response body: {
  "id": "1opf3ch9",
  "displayName": "Humility in the Age of Self-Promotion",
  "studioHost": "humility-cms",
  "isBlocked": false,
  "isDisabled": false,
  "isDisabledByUser": false,
  "metadata": {
    "color": "#325156"
  },
  "maxRetentionDays": 3,
  "activityFeedEnabled": true,
  "createdAt": "2018-08-15T17:30:50.008Z",
  "updatedAt": "2020-12-09T16:29:06.916Z",
  "deletedAt": null,
  "organizationId": null,
  "members": [
    {
      "id": "peqXQMjXy",
      "role": "administrator",
      "isRobot": false
    },
    {
      "id": "pd6rFF7qj",
      "role": "administrator",
      "isRobot": false
    },
    {
      "id": "pFNYNbIiT",
      "role": "write",
      "isRobot": false
    },
    {
      "id": "pfPvr8ZZ8",
      "role": "administrator",
      "isRobot": false
    }
  ],
  "pendingInvites": 0
} +0ms
✔ Checking project info
✔ Clearing output folder (5ms)
✔ Building Sanity (22465ms)
✔ Building index document (27ms)
✔ Minifying JavaScript bundles (20310ms)
✔ Verifying local content
⠋ Deploying to Sanity.Studio  sanity:client [2] HTTP POST <https://1opf3ch9.api.sanity.io/v1/deploy> +44s
  sanity:client [2] Request headers: {
  "Accept": "application/json",
  "User-Agent": "@sanity/client 0.147.0",
  "Authorization": "<redacted>"
} +1ms
⠸ Deploying to Sanity.Studio  sanity:client [2] Response code: 401 Unauthorized +300ms
  sanity:client [2] Response body: {
  "statusCode": 401,
  "error": "Unauthorized",
  "message": "User must be an administrator or a token with deploy rights to perform this operation"
} +0ms
  sanity:client [2] ERROR: Unauthorized - User must be an administrator or a token with deploy rights to perform this operation +1ms
✖ Deploying to Sanity.Studio
Error: You've been logged out. Log back in again with "sanity login"
    at onError (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1902:1974)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2820:241
    at Array.reduce (<anonymous>)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2820:225
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2808:965
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2808:1028
    at x (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2856:1442)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2856:2885
    at u.<anonymous> (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1554:181)
(base) Josephs-MBP-2:cms jiovino$ 
Apr 15, 2021, 8:42 PM
Thanks again - it runs into the same issue –1. I login, successfully,
2. it goes partway through the Debug, and then throws the Error: You’ve been logged out.

Perhaps there’s something in these Debug results that could help?
Here’s what happens:

$ sanity login
? Login type GitHub

Opening browser at <https://api.sanity.io/v1/auth/login/github?type=listen&uuid=129e2140b0d883478ed652a14c064ef3&source=cli>

Login successful
(base) Josephs-MBP-2:cms jiovino$ DEBUG=sanity* sanity deploy
  sanity:cli CLI installed at /usr/local/lib/node_modules/@sanity/cli/bin +0ms
  sanity:cli Less than 12 hours since last check, skipping update check +11ms
  sanity:cli Less than 12 hours since last nag, skipping +1ms
  sanity:cli No group found with name "deploy", looking for command +455ms
  sanity:cli Found command in default group with name "deploy" +0ms
  sanity:cli Reading "/Users/jiovino/projects/humility-monolith/cms/sanity.json" +1ms
  sanity:cli Running command "deploy" +2ms
⠋ Checking project info  sanity:client [1] HTTP GET <https://1opf3ch9.api.sanity.io/v1/projects/1opf3ch9> +0ms
  sanity:client [1] Request headers: {
  "Accept": "application/json",
  "User-Agent": "@sanity/client 0.147.0",
  "Authorization": "<redacted>"
} +1ms
⠹ Checking project info  sanity:client [1] Response code: 200 OK +216ms
  sanity:client [1] Response body: {
  "id": "1opf3ch9",
  "displayName": "Humility in the Age of Self-Promotion",
  "studioHost": "humility-cms",
  "isBlocked": false,
  "isDisabled": false,
  "isDisabledByUser": false,
  "metadata": {
    "color": "#325156"
  },
  "maxRetentionDays": 3,
  "activityFeedEnabled": true,
  "createdAt": "2018-08-15T17:30:50.008Z",
  "updatedAt": "2020-12-09T16:29:06.916Z",
  "deletedAt": null,
  "organizationId": null,
  "members": [
    {
      "id": "peqXQMjXy",
      "role": "administrator",
      "isRobot": false
    },
    {
      "id": "pd6rFF7qj",
      "role": "administrator",
      "isRobot": false
    },
    {
      "id": "pFNYNbIiT",
      "role": "write",
      "isRobot": false
    },
    {
      "id": "pfPvr8ZZ8",
      "role": "administrator",
      "isRobot": false
    }
  ],
  "pendingInvites": 0
} +0ms
✔ Checking project info
✔ Clearing output folder (5ms)
✔ Building Sanity (22465ms)
✔ Building index document (27ms)
✔ Minifying JavaScript bundles (20310ms)
✔ Verifying local content
⠋ Deploying to Sanity.Studio  sanity:client [2] HTTP POST <https://1opf3ch9.api.sanity.io/v1/deploy> +44s
  sanity:client [2] Request headers: {
  "Accept": "application/json",
  "User-Agent": "@sanity/client 0.147.0",
  "Authorization": "<redacted>"
} +1ms
⠸ Deploying to Sanity.Studio  sanity:client [2] Response code: 401 Unauthorized +300ms
  sanity:client [2] Response body: {
  "statusCode": 401,
  "error": "Unauthorized",
  "message": "User must be an administrator or a token with deploy rights to perform this operation"
} +0ms
  sanity:client [2] ERROR: Unauthorized - User must be an administrator or a token with deploy rights to perform this operation +1ms
✖ Deploying to Sanity.Studio
Error: You've been logged out. Log back in again with "sanity login"
    at onError (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1902:1974)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2820:241
    at Array.reduce (<anonymous>)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2820:225
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2808:965
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2808:1028
    at x (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2856:1442)
    at /usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:2856:2885
    at u.<anonymous> (/usr/local/lib/node_modules/@sanity/cli/bin/sanity-cli.js:1554:181)
(base) Josephs-MBP-2:cms jiovino$ 
Apr 15, 2021, 8:42 PM
There are. I’m guessing it’s due to your @sanity/client version. Any chance you’d be willing to update?
Apr 15, 2021, 8:44 PM
sanity:client [2] ERROR: Unauthorized - User must be an administrator or a token with deploy rights to perform this operation +1ms
Aha. I think this may be it. I only have Read + Write access – gotta get Admin permission. I will update and try again as well.
Apr 15, 2021, 8:45 PM
Oh. For sure that’s it. I should have kept scrolling!
Apr 15, 2021, 8:45 PM
Thank you so much!!!!
Apr 15, 2021, 8:46 PM

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.

Was this answer helpful?