{"id":20626712,"url":"https://github.com/dimensionsoftware/koa-shopify-auth","last_synced_at":"2026-04-16T21:36:20.852Z","repository":{"id":150980572,"uuid":"165326741","full_name":"DimensionSoftware/koa-shopify-auth","owner":"DimensionSoftware","description":"a soft fork of the official @shopify/koa-shopify-auth that fixes the enable_cookies route","archived":false,"fork":false,"pushed_at":"2019-01-12T03:17:03.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-17T06:27:38.206Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DimensionSoftware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-11T23:49:05.000Z","updated_at":"2019-01-12T03:17:04.000Z","dependencies_parsed_at":"2023-05-19T04:00:34.667Z","dependency_job_id":null,"html_url":"https://github.com/DimensionSoftware/koa-shopify-auth","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimensionSoftware%2Fkoa-shopify-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimensionSoftware%2Fkoa-shopify-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimensionSoftware%2Fkoa-shopify-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DimensionSoftware%2Fkoa-shopify-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DimensionSoftware","download_url":"https://codeload.github.com/DimensionSoftware/koa-shopify-auth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242483345,"owners_count":20135784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T13:14:28.992Z","updated_at":"2025-12-06T21:02:29.897Z","avatar_url":"https://github.com/DimensionSoftware.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `@dimensionsoftware/koa-shopify-auth`\n\n[![Build Status](https://travis-ci.org/Shopify/quilt.svg?branch=master)](https://travis-ci.org/Shopify/quilt)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md) [![npm version](https://badge.fury.io/js/%40shopify%2Fkoa-shopify-auth.svg)](https://badge.fury.io/js/%40shopify%2Fkoa-shopify-auth)\n\nThis is a soft fork of [@shopify/koa-shopify-auth](https://github.com/Shopify/quilt/tree/master/packages/koa-shopify-auth) that fixes one small Oauth bug.\n\nMiddleware to authenticate a [Koa](http://koajs.com/) application with [Shopify](https://www.shopify.ca/).\n\nSister module to [`@shopify/shopify-express`](https://www.npmjs.com/package/@shopify/shopify-express), but simplified.\n\nFeatures you might know from the express module like the webhook middleware and proxy will be presented as their [own packages instead](https://github.com/Shopify/quilt/blob/master/packages/koa-shopify-graphql-proxy/README.md).\n\n## Installation\n\n```bash\n$ yarn add @dimensionsoftware/koa-shopify-auth\n```\n\n## Usage\n\nThis package exposes `shopifyAuth` by default, and `verifyRequest` as a named export.\n\n```js\nimport shopifyAuth, {verifyRequest} from '@shopify/koa-shopify-auth';\n```\n\n### shopifyAuth\n\nReturns an authentication middleware taking up (by default) the routes `/auth` and `/auth/callback`.\n\n```js\napp.use(\n  shopifyAuth({\n    // if specified, mounts the routes off of the given path\n    // eg. /shopify/auth, /shopify/auth/callback\n    // defaults to ''\n    prefix: '/shopify',\n    // your shopify app api key\n    apiKey: SHOPIFY_API_KEY,\n    // your shopify app secret\n    secret: SHOPIFY_SECRET,\n    // scopes to request on the merchants store\n    scopes: ['write_orders, write_products'],\n    // set access mode, default is 'online'\n    accessMode: 'offline',\n    // callback for when auth is completed\n    afterAuth(ctx) {\n      const {shop, accessToken} = ctx.session;\n\n      console.log('We did it!', accessToken);\n\n      ctx.redirect('/');\n    },\n  }),\n);\n```\n\n#### `/auth`\n\nThis route starts the oauth process. It expects a `?shop` parameter and will error out if one is not present. To install it in a store just go to `/auth?shop=myStoreSubdomain`.\n\n### `/auth/callback`\n\nYou should never have to manually go here. This route is purely for shopify to send data back during the oauth process.\n\n### verifyRequest\n\nReturns a middleware to verify requests before letting them further in the chain.\n\n```javascript\napp.use(\n  verifyRequest({\n    // path to redirect to if verification fails\n    // defaults to '/auth'\n    authRoute: '/foo/auth',\n    // path to redirect to if verification fails and there is no shop on the query\n    // defaults to '/auth'\n    fallbackRoute: '/install',\n  }),\n);\n```\n\n### Example app\n\n```javascript\nimport 'isomorphic-fetch';\n\nimport Koa from 'koa';\nimport session from 'koa-session';\nimport shopifyAuth, {verifyRequest} from '@shopify/koa-shopify-auth';\n\nconst {SHOPIFY_API_KEY, SHOPIFY_SECRET} = process.env;\n\nconst app = new Koa();\napp.keys = [SHOPIFY_SECRET];\n\napp\n  // sets up secure session data on each request\n  .use(session(app))\n\n  // sets up shopify auth\n  .use(\n    shopifyAuth({\n      apiKey: SHOPIFY_API_KEY,\n      secret: SHOPIFY_SECRET,\n      scopes: ['write_orders, write_products'],\n      afterAuth(ctx) {\n        const {shop, accessToken} = ctx.session;\n\n        console.log('We did it!', accessToken);\n\n        ctx.redirect('/');\n      },\n    }),\n  )\n\n  // everything after this point will require authentication\n  .use(verifyRequest())\n\n  // application code\n  .use(ctx =\u003e {\n    ctx.body = '🎉';\n  });\n```\n\n## Gotchas\n\n### Fetch\n\nThis app uses `fetch` to make requests against shopify, and expects you to have it polyfilled. The example app code above includes a call to import it.\n\n### Session\n\nThough you can use `shopifyAuth` without a session middleware configured, `verifyRequest` expects you to have one. If you don't want to use one and have some other solution to persist your credentials, you'll need to build your own verifiction function.\n\n### Testing locally\n\nBy default this app requires that you use a `myshopify.com` host in the `shop` parameter. You can modify this to test against a local/staging environment via the `myShopifyDomain` option to `shopifyAuth` (e.g. `myshopify.io`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimensionsoftware%2Fkoa-shopify-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimensionsoftware%2Fkoa-shopify-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimensionsoftware%2Fkoa-shopify-auth/lists"}