
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@fdy/koa-shopify-auth
Advanced tools
[](https://travis-ci.org/Shopify/quilt) [](LICENSE.md) [ the routes /auth
and /auth/callback
.
app.use(
shopifyAuth({
// if specified, mounts the routes off of the given path
// eg. /shopify/auth, /shopify/auth/callback
// defaults to ''
prefix: '/shopify',
// your shopify app api key
apiKey: SHOPIFY_API_KEY,
// your shopify app secret
secret: SHOPIFY_SECRET,
// scopes to request on the merchants store
scopes: ['write_orders, write_products'],
// set access mode, default is 'online'
accessMode: 'offline',
// callback for when auth is completed
afterAuth(ctx) {
const {shop, accessToken} = ctx.session;
console.log('We did it!', accessToken);
ctx.redirect('/');
},
}),
);
/auth
This 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
.
/auth/callback
You should never have to manually go here. This route is purely for shopify to send data back during the oauth process.
Returns a middleware to verify requests before letting them further in the chain.
app.use(
verifyRequest({
// path to redirect to if verification fails
// defaults to '/auth'
authRoute: '/foo/auth',
// path to redirect to if verification fails and there is no shop on the query
// defaults to '/auth'
fallbackRoute: '/install',
}),
);
import 'isomorphic-fetch';
import Koa from 'koa';
import session from 'koa-session';
import shopifyAuth, {verifyRequest} from '@shopify/koa-shopify-auth';
const {SHOPIFY_API_KEY, SHOPIFY_SECRET} = process.env;
const app = new Koa();
app.keys = [SHOPIFY_SECRET];
app
// sets up secure session data on each request
.use(session({ secure: true, sameSite: 'none' }, app))
// sets up shopify auth
.use(
shopifyAuth({
apiKey: SHOPIFY_API_KEY,
secret: SHOPIFY_SECRET,
scopes: ['write_orders, write_products'],
afterAuth(ctx) {
const {shop, accessToken} = ctx.session;
console.log('We did it!', accessToken);
ctx.redirect('/');
},
}),
)
// everything after this point will require authentication
.use(verifyRequest())
// application code
.use(ctx => {
ctx.body = '🎉';
});
This 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.
Though 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.
By 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
).
FAQs
[](https://travis-ci.org/Shopify/quilt) [](LICENSE.md) [![npm version](https://badge.fury.io/js/%40shopify%2Fkoa-shopi
The npm package @fdy/koa-shopify-auth receives a total of 3 weekly downloads. As such, @fdy/koa-shopify-auth popularity was classified as not popular.
We found that @fdy/koa-shopify-auth demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.