Jackson Cunningham
Jackson Cunningham

Reputation: 5073

Manually create Shopify session in console using shopify_token

I have a store who installed my app, but the webhook didn't get created. Can I manually connect to the API using that shop's shopify_token so that I can manually create the webhook?

Thanks!

Upvotes: 0

Views: 844

Answers (2)

Andrew Chi
Andrew Chi

Reputation: 69

You may try this solution. It's more cleaner and easier to use.

# app/models/shop.rb

def with_shopify!
  session = ShopifyAPI::Session.new(shopify_domain, shopify_token)
  ShopifyAPI::Base.activate_session(session)
end

In rails console you can write this:

Shop.first.with_shopify!

Upvotes: 1

davids
davids

Reputation: 6371

Yes, you can (take a look at the Webhook resource in the Shopify API). In Rails console, you'd do something like this:

shopify_session = ShopifyAPI::Session.new(<shopify_domain>, <shop_token>)
ShopifyAPI::Base.activate_session(shopify_session)
shopify_shop = ShopifyAPI::Shop.current

ShopifyAPI::Webhook.create(topic: <event>, address: <your_app_endpoin>)

Upvotes: 1

Related Questions