Distinguish callback URL

Highlighted
New Member
5 0 0

Hi,

Install URL: http://localhost:4000/shopify

Callback URL: http://localhost:4000/shopify/callback

Everything works fine. However, Im not able to figure out following:

When app is installed for first, it goes to install URL(without session in query) and then to callback url after permissions are accepted. 

When we click on the installed app in list on store, it gets back to install URL(with session in query) and then to callback url(no permissions are shown this time). 

Is there any way to identify that CALLBACK URL is being called for first time install of app OR opening already installed app? Please help.

0 Likes
Highlighted
Shopify Partner
140 2 22

Hey,

You need to use a tunneling service to expose local host to the internet. Shopify recommend NGROK. So, for local development your new address would be something's like ngrok.dsadsa.com

Also, we list a https and a http address in our callback url settings.

Good luck,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

0 Likes
Highlighted
New Member
5 0 0

@OliUK

I understand that. Please read my question again. It is not about how can I expose my URLs to internet. Server is already setup. For testing purpose, Im using localhost.

Callback URL will be called when

a) user install app for first time

b) app is already installed and user click on that app in store. https://shop-name.com/admin/apps

My question is that is there any way to figure out if callback url is called to install app or opening already installed app. I hope you will understand my concern now.

0 Likes
Highlighted
New Member
5 0 0

@OliUK 

To make it even more clear, I want to do something after app is installed. After installation it comes back to callback url so I can do that in callback url. But same callback url is called when INSTALLED app is clicked on in store. So callback url is multipurpose. How can I identify if callback url is called after installation or clicking in store?

0 Likes
Highlighted
Shopify Partner
140 2 22

Hi,

I still don’t quite see how your local host URLs would work (even in testing) as your app URL would have to be exposed to the web in order to load the app into the Shopify dashboard. Anyway, I might be missing something, to answer the rest of your question:

Ok I think I understand what you’re trying to do. I’ve never tried to do this the way you’re describing, so I can’t help you there. Why don’t you just  run some code before you create a database entry for the shop? v.rough example:

@shop = ShopifyAPI::Shop.current
if Shop.find_by(shopify_domain: @shop.myshopify_domain)
      #shop already exsists
else
     #some logic here
     @db_shop = Shop.new
     @db_shop.shopify_domain = @shop.myshopify_domain
     #etc
     @db_shop.save
end

 

Cheers,

Oli

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

0 Likes
Highlighted
New Member
5 0 0

@OliUK 

Thanks for replying back.

Im not saving shop and access token as soon as I get it. I install the app, it hits callback api, on receiving access token, it redirect to my app's user registration page. On registering, Im saving that token and shop in db.

So in case, user installs the app but does not register, how can I figure it out that app is already installed so don't perform specific actions(such as sending notification that a shop has installed your app)

 

 

0 Likes
Highlighted
Shopify Partner
140 2 22

Ah I understand. That's a tricky one, I take it there aren't params sent to the callback URL from Shopify that you can use?

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

 

0 Likes
Highlighted
New Member
5 0 0
shop, hmac, code, state, signature, timestamp. These are params which I get during callback which I don't find helpful to resolve my problem.
 
Is there anyway I can use these to identify if app is already installed?
0 Likes
Highlighted
Shopify Partner
140 2 22

At this point I only really know as much as you do. I take it the 'state' param isn't returning anything promising.

Again, if you had a list of shop names stored in your database, you could just check to see if the shop in shop param had an entry yet.

Here's a link to the Rails Shopify callback controller , even if you're not a Ruby developer, it's really nicely written and easy to understand. Maybe there's a clue in there.

 

——————————

Founder @ www.preproduct.io

Test and make sales for future products

 

0 Likes