Created
July 24, 2025 13:40
-
-
Save fabiensebban/e05d82d39715973014637f8949ad9ef2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code can be used to decode the session token coming from the | |
# Customer UI extension: https://shopify.dev/docs/api/customer-account-ui-extensions/2024-10/apis/session-token | |
require 'jwt' | |
require 'json' | |
# Replace with your app's client secret from the Partner Dashboard | |
SHOPIFY_CLIENT_SECRET = "XXX" | |
# Token present in the Authorization header of the request | |
token = "yyyy" | |
decoded_token = JWT.decode(token, SHOPIFY_CLIENT_SECRET, true, { algorithm: 'HS256' }) | |
# Shopify's session token payload is in the first element of the array | |
payload = decoded_token[0] | |
# Example: Log the customer id or destination shop | |
puts "Verified session for shop: #{payload['dest']}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment