Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vtalas committed Apr 3, 2024
1 parent 35d2168 commit 94e8be5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/appmixer/shopify/routes.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
const crypto = require('crypto');
const auth = require('./auth');

module.exports = function(context) {

const CustomerDataRequest = require('./CustomerDataRequest')(context);
const CustomerRedactRequest = require('./CustomerRedactRequest')(context);
const ShopRedactRequest = require('./ShopRedactRequest')(context);

/**
* Shopify install link, Shopify calls this link to install the app:
* https://api.qa.appmixer.com/plugins/appmixer/shopify/install?shop=appmixer.myshopify.com
* Set the base url (https://api.qa.appmixer.com/plugins/appmixer/shopify) in the Shopify app settings.
*/
context.http.router.register({
method: 'GET',
path: '/install',
options: {
handler: (req, h) => {

const { shop } = req.query;
const clientId = encodeURIComponent(context.config.clientId);
const redirect_uri = encodeURIComponent(context.config.appStoreInstallRedirectUri);
const scopes = encodeURIComponent(auth.definition.scope.join(','));

const authUrl = `https://${shop}/admin/oauth/authorize?client_id=${clientId}&redirect_uri=${redirect_uri}&scope=${scopes}`;

return h.redirect(authUrl);
},
auth: false
}
});

context.http.router.register({
method: 'POST',
path: '/customers/data_request',
Expand Down

0 comments on commit 94e8be5

Please sign in to comment.