Shopify / shopify-api-ruby

ShopifyAPI is a lightweight gem for accessing the Shopify admin REST and GraphQL web services.
MIT License
1.06k stars 473 forks source link

Add expired? method to check if session is expired #1244

Closed gbzodek closed 1 year ago

gbzodek commented 1 year ago

Description

What is the problem it is solving?

There isn't currently a method available to check if an auth session is expired (for online tokens mainly). It's up to each app to implement the method if they want to do such check. This PR adds an expired? method to the Session that will check the expires attribute if it exists.

What is the context of these changes?

We are planning to add a check on the expiry date in shopify_app to trigger an early re-auth, and having that method will make the check cleaner

What is the impact of this PR?

A new method can be used to check if the session is expired. No impact as long as it's not used

How has this been tested?

Unit tests provided in the PR

Checklist: