Ability to use Json Web Token to show / hide pages

New Member
3 0 0

We have an affiliate who will link their customers to a specific page on our site. They're sending a JSON web token that we need to verify to approve whether they can see the page or not. Just looking for guidance to see if we can have the ability to run any server-side functions like validating the JWT or help with what might be possible within Shopify? I have created a simple JWT app on Heroku that returns a simple yes or no reponse if the token is valid, but am stuck on how to use it within shopify.

0 Likes
Highlighted
Shopify Expert
9965 84 1469

Liquid isn't going to be able to make a call to your external system so that's going to leave a JavaScript AJAX call instead.

Is this on a product page? Something else? Perhaps the external tool validating the user also returns the content to display in an ajax response.

Maybe you instead get customers to log into an account first that you've already validated in some way.

 

Some further context would help.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
New Member
3 0 0

Hey Jason! This is for a collection page. The request for this has come from an affiliate to show a page based on a JWT. Before this, I had set up a simple liquid boolean based on a query string (as they're visitors without tags) in the URL but they would prefer something more secure. 

 

The external tool is a simple python app that looks for a token in the header — here is a duplicate example of it https://jwt-example-app.herokuapp.com/validate-token — I was hoping to somehow utilise this when their customers lands on the collection. 

 

If that's not possible, I'd definitely be interested in how to serve the content with AJAX once they are validated. 

0 Likes