Focuses on API authentication, access scopes, and permission management.
Hello!
old_version ==> new_version
Rails 6.1.7
shopify_app 21.2.0 ==> 21.7.0
shopify_api 12.2.1 ==> 13.3.0
I'm trying to update Shopify API 2022-10 to 2023-04 but I'm running into errors related to session storage. I understand that session storage is no longer the responsibility of shopify_api gem since 12.3.0
https://github.com/Shopify/shopify-api-ruby/blob/main/CHANGELOG.md#version-1230
but removing this line:
# config/initializers/shopify_app.rb
#...
session_storage: ShopifyApp::SessionRepository,
#...
results in other errors such as:
Failure/Error:
allow(ShopifyAPI::Utils::SessionUtils).to(
receive(:load_current_session).and_return(
ShopifyAPI::Auth::Session.new(
shop: account.shopify_domain,
scope: ShopifyApp.configuration.scope
)
)
)
ShopifyAPI::Utils::SessionUtils does not implement: load_current_session
Any help would be greatly appreciated.
Thanks!
Hi Craftonix,
The error is indicating that the SessionUtils
does not have the method load_current_session
.
As of version 12.3.0, the shopify_api
gem has deprecated the SessionRepository
and moved session storage responsibilities to the shopify_app
gem. This means you now need to manage the sessions yourself.
You should update your test setup to create a session explicitly. Here's an example of how you might do this:
session = ShopifyAPI::Session.new(
domain: account.shopify_domain,
token: account.shopify_token,
api_version: '2023-04'
)
ShopifyAPI::Base.activate_session(session)
In the above code, account.shopify_domain
should be your shop's domain, and account.shopify_token
should be your access token.
If you're looking to stub the session for tests, you can do something like:
session = instance_double('ShopifyAPI::Session', valid?: true, site: "https://#{account.shopify_domain}")
allow(ShopifyAPI::Session).to receive(:new).and_return(session)
This will return the stubbed session whenever new
is called on ShopifyAPI::Session
.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Thanks Liam for the quick and helpful reply!
I will test your suggestion and let you know soon.
Just curious, where can I find the documentatin for API 2022-10 ? (I know it's one year old and no longer supported, but I'd like to know)
Hi,
I have posted a reply twice here and for some reasone this interface deletes my post!
Any chance we can email?
Hi you should be able to DM me on here - regarding the documentation for 2022-10, this isn't stored on shopify.dev, we only display the active versions docs.
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Any news?