How to use the @shopify/koa-shopify-auth function in @shopify/koa-shopify-auth

To help you get started, we’ve selected a few @shopify/koa-shopify-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / unite-react-node-app-workshop / server / index.js View on Github external
import createShopifyAuth, {
  createVerifyRequest,
} from '@shopify/koa-shopify-auth';
import renderReactApp from './render-react-app';
import webpack from 'koa-webpack';
import graphQLProxy from '@shopify/koa-shopify-graphql-proxy';

dotenv.config();

const {SHOPIFY_API_KEY, SHOPIFY_SECRET} = process.env;
const app = new Koa();

app.use(session(app));

app.use(
  createShopifyAuth({
    // your shopify app's api key
    apiKey: SHOPIFY_API_KEY,
    // your shopify app's api secret
    secret: SHOPIFY_SECRET,
    // our app's permissions
    // we need to write products to the user's store
    scopes: ['write_products'],
    // our own custom logic after authentication has completed
    afterAuth(ctx) {
      const {shop, accessToken} = ctx.session;

      console.log('We did it!', shop, accessToken);

      ctx.redirect('/');
    },
  }),

@shopify/koa-shopify-auth

Middleware to authenticate a Koa application with Shopify

MIT
Latest version published 2 years ago

Package Health Score

47 / 100
Full package analysis

Similar packages