Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning about Sessions?? #1084

Closed
resistorsoftware opened this issue Dec 27, 2022 · 8 comments
Closed

Warning about Sessions?? #1084

resistorsoftware opened this issue Dec 27, 2022 · 8 comments

Comments

@resistorsoftware
Copy link

resistorsoftware commented Dec 27, 2022

Shopify App v 21.3.1, and Shopify API v12.3

In my console I see this when running my App:

[ ShopifyAPI | WARN ] The use of SessionStorage in the API library has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Upgrading to `shopify_app` 21.3 will allow you to remove session_storage from the API library Context configuration.

So does that mean in the App initializer, we get rid of session storage?

Like delete this line?

ShopifyAPI::Context.setup(
   ====>   session_storage: ShopifyApp::SessionRepository, 

Is that what we're talking about?

@seshna
Copy link

seshna commented Jan 13, 2023

any answer to this?

@resistorsoftware
Copy link
Author

Ha! You'd think the Shopify team or some other expert would've answered DUH, Yes... and moved on from this issue. But of course no. It even bit me last night again as I deployed yet another App, this time on v21.4 and when I saw this in the logs I was like WTF. I hate this... all these deprecations in GQL and other code will soon enough turn 8000 App developers into butternut squash brains.

@mikelieser
Copy link

shopify_app 21.4.0
shopify_api 12.4.0

Got the same warning while starting the app. Removed

session_storage: ShopifyApp::SessionRepository,

from shopify_app.rb in ShopifyAPI::Context.setup(

and warning is gone.

see https://github.com/Shopify/shopify-api-ruby/blob/main/lib/shopify_api/context.rb#L85

@seshna
Copy link

seshna commented Jan 30, 2023

shopify_app 21.4.0 shopify_api 12.4.0

Got the same warning while starting the app. Removed

session_storage: ShopifyApp::SessionRepository,

from shopify_app.rb in ShopifyAPI::Context.setup(

and warning is gone.

see https://github.com/Shopify/shopify-api-ruby/blob/main/lib/shopify_api/context.rb#L85

thank you. I am curious though, what actually is the session storage used for? is there anything further we have to do after we remove this line? what implications does removing this line actually have?

@mikelieser
Copy link

mikelieser commented Jan 30, 2023

see https://github.com/Shopify/shopify-api-ruby/blob/main/CHANGELOG.md#version-1230

#1055 Makes session_storage optional. Configuring the API with session_storage is now deprecated. Session persistence is handled by the shopify_app gem if using Rails.

Update: My understanding is > nothing to do, everything is still working :)

@nelsonwittwer
Copy link
Contributor

Session persistence is deprecated from the API library. The changelog @mikelieser pointed out has the relevant details (thanks for sharing). The shpoify_app gem will be new the session persistence owner.

@jaspertandy
Copy link

jaspertandy commented Apr 18, 2023

But what if you're not using Rails? I'm just using a simple command line app and it's complaining about me using session storage but what else is there? The README for this project still shows the way I'm doing things as the way things should be done.

So how do I use this library now, on a private app, when sessions in the API are deprecated and I'm not using Rails? Do I ignore the deprecation warning? I'm making changes here to fix another deprecation and now I'm having to deal with this instead. I'd appreciate some guidance on this please @nelsonwittwer

ShopifyAPI::Context.setup(
  api_key: ENV['SHOPIFY_API_KEY'],
  host_name: ENV['SHOPIFY_HOSTNAME'],
  scope: "read_customers, write_fulfillments, read_fulfillments, write_inventory, read_inventory, write_orders, read_orders, write_products, read_products",

  private_shop: ENV['SHOPIFY_HOSTNAME'],
  api_secret_key: ENV['SHOPIFY_BEARER_TOKEN'],

  session_storage: ShopifyAPI::Auth::FileSessionStorage.new,
  is_embedded: false,
  is_private: true,
  api_version: "2023-04"
)
W, [2023-04-18T10:58:31.048729 #1]  WARN -- : [ ShopifyAPI | WARN | host ] The use of SessionStorage in the API library has been deprecated. The ShopifyAPI will no longer have responsibility for session persistence. Upgrading to `shopify_app` 21.3 will allow you to remove session_storage from the API library Context configuration.

This is deprecated, but if I remove the session_storage line I just get an error.

/usr/local/bundle/gems/shopify_api-12.5.0/lib/shopify_api/utils/session_utils.rb:132:in `validate_session_storage_for_deprecated_utils': session_storage is required in ShopifyAPI::Context when using deprecated Session utility methods. (ShopifyAPI::Errors::SessionStorageError)
        from /usr/local/bundle/gems/sorbet-runtime-0.5.10784/lib/types/private/methods/call_validation.rb:256:in `bind_call'
        from /usr/local/bundle/gems/sorbet-runtime-0.5.10784/lib/types/private/methods/call_validation.rb:256:in `validate_call'
        from /usr/local/bundle/gems/sorbet-runtime-0.5.10784/lib/types/private/methods/_methods.rb:275:in `block in _on_method_added'
        from /usr/local/bundle/gems/shopify_api-12.5.0/lib/shopify_api/utils/session_utils.rb:20:in `load_current_session'
        from /usr/local/bundle/gems/sorbet-runtime-0.5.10784/lib/types/private/methods/call_validation.rb:256:in `bind_call'
        from /usr/local/bundle/gems/sorbet-runtime-0.5.10784/lib/types/private/methods/call_validation.rb:256:in `validate_call'
        from /usr/local/bundle/gems/sorbet-runtime-0.5.10784/lib/types/private/methods/_methods.rb:275:in `block in _on_method_added'
        from app.rb:20:in `<main>'

@heythisisnate
Copy link

I have the same question. How is session storage handled for a command-line only app?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants