Python Shopify API Session Auth Error

Highlighted
New Member
1 0 0

Hi, I'm trying to use the Python Shopify API and in the initial stages of when the merchant is returned to the whitelisted url. I'm able to verify parameters and create a Session but I cannot activate the session. Not sure what I'm doing wrong where I receive a cls.version = session.api_version.name. AttributeError: 'str' object has no attribute 'name'

 

@app.route("/installed")
def installed():
    store_url = request.args.get('shop')
    shopify.Session.setup(api_key=os.environ['SHOPIFY_API_KEY'],
                                secret=os.environ['SHOPIFY_SECRET_KEY'],
                                api_version=os.environ['API_VERSION'])
    store_session = shopify.Session(store_url, os.environ['API_VERSION'])
    valid_session = shopify.Session.validate_params(request.args)
    access_token = store_session.request_token(request.args)

    shopify.Session.setup(api_key=os.environ['SHOPIFY_API_KEY'],
                                secret=os.environ['SHOPIFY_SECRET_KEY'],
                                api_version=os.environ['API_VERSION'])
    shop_url = request.args.get('shop')
    new_session = shopify.Session(shop_url, api_version=os.environ['API_VERSION'], token=access_token)

    shopify.ShopifyResource.activate_session(new_session)

    shop = shopify.Shop.current()

I receive this error while trying to activate_session() :

.../site-packages/shopify/base.py", line 196, in activate_session
    cls.version = session.api_version.name
AttributeError: 'str' object has no attribute 'name'

Hopefully someone can help me out with this

0 Likes