Skip to content

Commit fc2f380

Browse files
authored
Merge pull request #6089 from Shopify/update-cli-auth-error-message
Add CLI theme login auth error next steps
2 parents 3a98d96 + b1feb1d commit fc2f380

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

.changeset/fifty-flowers-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/cli-kit': patch
3+
---
4+
5+
Add CLI theme login auth error next steps

packages/cli-kit/src/private/node/session/exchange.test.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -172,18 +172,7 @@ describe('refresh access tokens', () => {
172172
const got = () => refreshAccessToken(identityToken)
173173

174174
// Then
175-
await expect(got).rejects.toThrowError(
176-
'You are not authorized to use the CLI to develop in the provided store.' +
177-
'\n\n' +
178-
"You can't use Shopify CLI with development stores if you only have Partner " +
179-
'staff member access. If you want to use Shopify CLI to work on a development store, then ' +
180-
'you should be the store owner or create a staff account on the store.' +
181-
'\n\n' +
182-
"If you're the store owner, then you need to log in to the store directly using the " +
183-
'store URL at least once before you log in using Shopify CLI. ' +
184-
'Logging in to the Shopify admin directly connects the development ' +
185-
'store with your Shopify login.',
186-
)
175+
await expect(got).rejects.toThrowError('You are not authorized to use the CLI to develop in the provided store.')
187176
})
188177

189178
describe('when there is a store in the request params', () => {
@@ -198,16 +187,7 @@ describe('refresh access tokens', () => {
198187

199188
// Then
200189
await expect(got).rejects.toThrowError(
201-
'You are not authorized to use the CLI to develop in the provided store: bob.myshopify.com' +
202-
'\n\n' +
203-
"You can't use Shopify CLI with development stores if you only have Partner " +
204-
'staff member access. If you want to use Shopify CLI to work on a development store, then ' +
205-
'you should be the store owner or create a staff account on the store.' +
206-
'\n\n' +
207-
"If you're the store owner, then you need to log in to the store directly using the " +
208-
'store URL at least once before you log in using Shopify CLI. ' +
209-
'Logging in to the Shopify admin directly connects the development ' +
210-
'store with your Shopify login.',
190+
'You are not authorized to use the CLI to develop in the provided store: bob.myshopify.com',
211191
)
212192
})
213193
})

packages/cli-kit/src/private/node/session/exchange.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,9 @@ interface TokenRequestResult {
196196
}
197197

198198
function tokenRequestErrorHandler({error, store}: {error: string; store?: string}) {
199-
const invalidTargetErrorMessage =
200-
`You are not authorized to use the CLI to develop in the provided store${store ? `: ${store}` : '.'}` +
201-
'\n\n' +
202-
"You can't use Shopify CLI with development stores if you only have Partner " +
203-
'staff member access. If you want to use Shopify CLI to work on a development store, then ' +
204-
'you should be the store owner or create a staff account on the store.' +
205-
'\n\n' +
206-
"If you're the store owner, then you need to log in to the store directly using the " +
207-
'store URL at least once before you log in using Shopify CLI. ' +
208-
'Logging in to the Shopify admin directly connects the development ' +
209-
'store with your Shopify login.'
199+
const invalidTargetErrorMessage = `You are not authorized to use the CLI to develop in the provided store${
200+
store ? `: ${store}` : '.'
201+
}`
210202

211203
if (error === 'invalid_grant') {
212204
// There's an scenario when Identity returns "invalid_grant" when trying to refresh the token
@@ -219,7 +211,11 @@ function tokenRequestErrorHandler({error, store}: {error: string; store?: string
219211
return new InvalidRequestError()
220212
}
221213
if (error === 'invalid_target') {
222-
return new InvalidTargetError(invalidTargetErrorMessage)
214+
return new InvalidTargetError(invalidTargetErrorMessage, '', [
215+
'Ensure you have logged in to the store using the Shopify admin at least once.',
216+
'Ensure you are the store owner, or have a staff account if you are attempting to log in to a development store.',
217+
'Ensure you are using the permanent store domain, not a vanity domain.',
218+
])
223219
}
224220
// eslint-disable-next-line @shopify/cli/no-error-factory-functions
225221
return new AbortError(error)

0 commit comments

Comments
 (0)