[API] Service is not valid for authentication

Shopify CLI was working earlier this morning, then I tried to push, publish and even rename my dev theme for my dev store and kept getting a 401 error.

Turns out even shopify theme dev is no longer working, which it was just 10 mins prior.

I feel like this is something upstream but I don’t have any contacts to confirm.

I have tried checking in all the places I know of:
Shopify Status - Check Shopify Server Status

Everything seems fine, so I’m not too sure what the issue could be. Is anyone else experiencing this?

Tooling and System info:

│  Tooling and System                                                                                                        │
│  Shopify CLI   3.76.2                                                                                                      │
│  OS            linux-amd64                                                                                                 │
│  Shell         /bin/bash                                                                                                   │
│  Node version  v23.9.0                                                                                                     

I’m building a theme locally for a dev store. Not sure what other info can help

$ shopify theme dev --store [redacted].myshopify.com

╭─ error ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                            │
│  GraphQL Error (Code: 401): {"response":{"errors":"[API] Service is not valid for                                          │
│  authentication","status":401,"headers":{}},"request":{"query":"mutation themeCreate($name: String!, $source: URL!,        │
│  $role: ThemeRole!) {\n  themeCreate(name: $name, source: $source, role: $role) {\n    theme {\n      id\n      name\n     │
│     role\n      __typename\n    }\n    userErrors {\n      field\n      message\n      __typename\n    }\n                 │
│  __typename\n  }\n}","variables":{"name":"Development (RANDOM-CODE-HERE)","source":"https://cdn.shopify.com/static/  │
│  online-store/theme-skeleton.zip","role":"DEVELOPMENT"}}}                                                                  │
│                                                                                                                           

Running with --verbose flag just shows the request failing at the same time, with some comments about the info being sent to BugSnag, if that’s any use?

Hi,

I can’t replicate on my side:


I’m on MacOS - I wonder if it’s something related to linux?

Not sure if this will help but try re-logging in, sometimes CLI auth token expires or something and it starts throwing 401s, re-logging helps.

Just ran into the same situation where pull/dev worked one minute and then didn’t a bit later. The comment above mine made me realize I had cycled having 2FA enabled on my account in the interim, which likely resulted in auth tokens getting rescinded so a simple re-login in the CLI solved the issue.

Thanks for all the responses. Unfortunately I was also unable to run the command shopify login as the CLI was saying that command didn’t exist. I suspect it was some sort of auth token issue, but I’m not familiar with how things work under the hood, so I was really left to just try “turning it off and on again”

That seemed to have worked, so I’m not too sure what this was.

This may be one of those “intermitent hard to diagnose and replicate” issues, which are always so much fun.

At least now there’s a thread with the error message that may shed some light for future users.

Appreciate everyone’s efforts to help!

Cheers

There is no shopify login command, it’s shopify auth, and it was definitely related to your auth token issue. This usually happens if you haven’t used the CLI for weeks or if you’ve updated auth-related account info like enabling 2FA or changing your password.

Thanks for the response @Gulam_Hussain_Quinn.

I believe I am a victim of another AI hallucination then, as the steps recommended to me two different times suggested to run shopify login.

I will attach the screenshots.

I imagine there may be some outdated docs somewhere that suggests that or something, otherwise you can copy the big players with their top-notch prompts “Do not hallucinate, do not make up answers that aren’t real” :wink:


and

As a newbie to the Shopify Dev world, I had assumed the issue was with my setup somehow, rather than the support content :slight_smile:

Next time I will definitely give shopify auth a go and see if that resolves it.

One other note, that may help in replicating/solving this: The steps that I believe caused my issue were

  1. Create an account on the live store
  2. Be granted limited (not Admin) permission
  3. Use shopify theme dev --store companylivestore - this did not work, possibly a bug? Support staff just said “You’re supposed to use the web editor” :warning: (support ticket here)[https://help.shopify.com/en/inbox/10131117]
  4. Setup a new store on same account (not a dev store, but a free trial store)
  5. Use shopify theme dev --store mytrialstore - this worked to do theme dev :white_check_mark:
  6. Setup a partner account with same email (as I couldn’t make a dev store as an internal member - in the interest of completeness Confusion around Non Admin or Partner · Issue #5513 · Shopify/cli)
  7. Setup a dev store with the partner account
  8. Use shopify theme dev --store partnerdevstore - this worked to do theme dev for about 30 mins :white_check_mark:
  9. Wait maybe 30 mins or so
  10. Then the 401 error occurred.

So maybe it’s just an edge case of an already authenticated token or something under the hood that then gets associated with a partner account. I can’t imagine it’s a super common flow, but it impacted me, nonetheless.

Hope this extra information may help in fixing the issue upstream (though it isn’t super simple to replicate and therefore diagnose)

I originally thought this was the answer and because the issue wasn’t occurring I didn’t feel I needed to validate it… However, I am getting an issue so I thought “YES! Now I can give this a go” only to find shopify auth also doesn’t have any login method.

$ shopify auth
Auth operations.

USAGE
  $ shopify auth COMMAND

COMMANDS
  auth logout  Logs you out of the Shopify account or Partner account and store.

I don’t understand how that answer could be correct…

Use the shopify auth logout command to log out, then run shopify theme dev or any other command to prompt re-login.

I could be wrong about saying that it definitely was auth token issue, but if logging out and logging back in fixes it, there’s a good chance the token was the issue.

Oh right, the logging in is implicit, but the logging out command is explicit. I see.

Thanks for the input, hopefully I don’t have to try it, but if I do, I’ll update this thread

1 Like