How to authenticate using dedicated shop domain using Python API

devdude
Excursionist
23 1 19

With the code below I am trying to start authentication/installation of my app on a new store:

 

_install_bp.route("/start")
def start():
    shopify_domain = request.args.get("shop")
    logger.info(f"Shopify app authentication started: shopify_domain={shopify_domain}, request.referrer={request.referrer}")
    shopify.Session.setup(api_key=current_app.config.get("shopify-api-key"), secret=current_app.config.get("shopify-api-secret"))
    shopify_session = shopify.Session(shop_url=shopify_domain, version=current_app.config.get("shopify-api-version"))
    permission_url = shopify_session.create_permission_url(shopify_scopes, url_for("shopify_install_bp.finish", _external=True))
    return render_template("shopify_install_bp/start.html", permission_url=permission_url)

 

This succeeds as long as as I refer to the store with shop argument equal to the myshopify form (merchbot-test.myshopify.com in my case). However as we all know, any respectable store will have a dedicated domain in addition. For my store that domain is bombcrater.com and running the code above will try (and fail misserably) to install the app to bombcrater.myshopify.com which is incorrect.

How can I get the correct myshopify name of a store given it's domain at authentication time?

 

 

https://www.merchbot.net
Replies 0 (0)