How to customize what happens after oauth and app installation has finished

How to customize what happens after oauth and app installation has finished

peterpot20
Shopify Partner
22 2 3

Hi, I am writing an app that has a custom action to do after a store owner has installed my app to their store. 
The configuration for auth looks like this:

 

 

auth: {
  path: "/api/auth",
  callbackPath: "/api/auth/callback",
}

 

 

In the index.js file, I created a new path and its behaviour like this:

 

 

app.get("/api/auth/callback", (_req, res) => {
  console.log('/api/auth/callback callback');
  console.log('_req: ', _req);
  console.log('res: ', res);
  res.redirect("/");
});

 

 

However, when I installed my app to a store, I don't see _req and res being printed to the console. Am I missing something?

My goal is to create a new "store" entry in my database when a new store install the app. I thought doing it at the end of OAuth makes sense but not exactly sure how to do that.

 

Thanks!

Reply 1 (1)

gsmaverick
Shopify Partner
21 3 4

It's hard to know what's wrong without more details about your setup. A few questions that would help shed more light on the issue:

  • Did you use one of the templates to build your app?
  • What file did you add the configuration for auth to?
  • When you run your app what happens after you click "Install App" on the OAuth Grant page?

 


@peterpot20 wrote:

My goal is to create a new "store" entry in my database when a new store install the app. I thought doing it at the end of OAuth makes sense but not exactly sure how to do that.


Creating your store entry in the OAuth callback handler is the right place to do it.