Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to reinstall if error during install #570

Closed
ashleyww93 opened this issue Jan 11, 2024 · 2 comments
Closed

Unable to reinstall if error during install #570

ashleyww93 opened this issue Jan 11, 2024 · 2 comments

Comments

@ashleyww93
Copy link

ashleyww93 commented Jan 11, 2024

Issue summary

If a user trys to install your app, and the backend has an error AFTER the session has been created. When try again you get the following error:

Received an error response (401 Unauthorized) from Shopify:
"[API] Invalid API key or access token (unrecognized login or wrong password)"
If you report this error, please include this id: 3df071e1-fb98-469f-a2de-ccc4ea88ab27
  • "@shopify/shopify-app-express": "^2.2.2",
    "@shopify/shopify-app-session-storage": "^1.1.9",
    "@shopify/shopify-app-session-storage-memory": "^1.0.11",
    "@shopify/shopify-app-session-storage-postgresql": "^1.1.10",
    "@shopify/shopify-app-session-storage-redis": "^1.1.9",
  • Node version:v18.16.0
  • Operating system: MacOS Ventura 13.2.1
Error: Received an error response (401 Unauthorized) from Shopify:
"[API] Invalid API key or access token (unrecognized login or wrong password)"
If you report this error, please include this id: 3df071e1-fb98-469f-a2de-ccc4ea88ab27
  File "/usr/src/app/node_modules/@shopify/shopify-api/lib/clients/http_client/http_client.js", line 193, col 23, in NewHttpClient.throwFailedRequest
    throw new ShopifyErrors.HttpResponseError({
  File "/usr/src/app/node_modules/@shopify/shopify-api/lib/clients/http_client/http_client.js", line 220, col 22, in NewHttpClient.<anonymous>
    this.throwFailedRequest(body, response);
  File "<anonymous>", in Generator.next
  File "/usr/src/app/node_modules/tslib/tslib.js", line 166, col 62, in fulfilled
    function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  File "node:internal/process/task_queues", line 95, col 5, in process.processTicksAndRejections

Expected behavior

If a 401 error happens, we should assume the store needs to be reinstalled

Actual behavior

The error is thrown, and the page never loads.

@paulomarg
Copy link
Contributor

Hi, thank you for raising this issue. The 401 response from Shopify means that the access token was not valid, which is probably a consequence of the error you mentioned. However, it can also happen for other reasons, like when an online access token expires, so the app needs to be able to handle these errors.

When you use one of the API clients to make requests, it'll throw an HttpResponseError error when we get a 401 back. When you catch that, you can use redirectOutOfApp to start the login process again (or handle the error differently if you want to).

For example:

    shopify.redirectOutOfApp({
      req,
      res,
      redirectUri: shopify.config.auth.path,
      shop: '<shop goes here>',
    });

Copy link
Contributor

We are closing this issue because we did not hear back regarding additional details we needed to resolve this issue. If the issue persists and you are able to provide the missing clarification we need, feel free to respond and reopen this issue.

We appreciate your understanding as we try to manage our number of open issues.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants