Failed to validate JWT: [JWT::ExpiredSignature] Signature has expired

twg
Shopify Partner
1 0 0

I have a embeded using the turbolinks template, I am using shopify_app gem 20.1 and I am trying to filter the products from shopify by the product title (I am basically doing a typeahead search so I want to get products that matches an specific term in the product title), long time ago (with shopify-app gem '12.0.7') I was able to do that by calling:

 

Product.where(title: query)

 

 

But looks like that's not possible anymore, and I have to use GraphQL, so I tried this (taken from https://shopify.github.io/shopify-api-ruby/usage/graphql.html😞

session = ShopifyAPI::Utils::SessionUtils.load_current_session(
      auth_header: request.headers["Authorization"],
      cookies: request.headers['cookies'],
      is_online: true
)
client = ShopifyAPI::Clients::Graphql::Admin.new(session: session)
query = <<~QUERY
    {
      products(first: 10, query: "title: *'Test'*") {
        edges {
          node {
            id
            productType
            title
            vendor
            featuredImage {
              src
            }
            images(first: 1) {
              edges {
                node {
                  src
                }
              }
            }
          }
        }
      }
    }
    QUERY

I am able to see the results of the query, meaning it all wente well, but on a next attempt I get the following error:

ShopifyApp::JWT] Failed to validate JWT: [JWT::ExpiredSignature] Signature has expired

Any idea why is this?

Reply 1 (1)

mikerowave
Shopify Staff (Retired)
22 3 2

Hi @twg!

 

That error suggests you may not be handling sessions correctly. I would recommend taking a look at the Known Issues and Caveats page of that guide for some insight.

 

I would also recommend opening an issue on the Github repo for this gem if you're not able to make any more progress.

Mike M (mikerowave) | API Support @ 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