BACK

how to not show up on shopify session

Invalid session token - fix the most annoying Shopify bug | L4 Webdesign all right so back with anot

L4 Webdesign

Updated on Mar 27,2023

Invalid session token - fix the most annoying Shopify bug | L4 Webdesign

The above is a brief introduction to how to not show up on shopify session

Let's move on to the first section of how to not show up on shopify session

Let TThunt's experts help you find the best TikTok product on your Shopify business!

Find TikTok products (It's Free)
No difficulty
No complicated process
Find winning products
3.5K Ratings

WHY YOU SHOULD CHOOSE TTHUNT

TThunt has the world's largest selection of TikTok products to choose from, and each product has a large number of advertising materials, so you can choose advertising materials for TikTok ads or Facebook ads without any hassle.

Invalid session token - fix the most annoying Shopify bug | L4 Webdesign

all right so back with another video,about a problem that i think every,shopify developer will have sooner or,later and that is the invalid session,token if you don't know what i'm talking,about i will show you a an example right,here so,um i've got my app right here and it's,this getting started page that you need,for uh the ux requirement for every,shopify app and this,page should show you which theme is,installed and if that theme has a theme,app blocks installed or not so in order,to find that out i created a controller,in my laravel backend which will check,which theme there is and if that theme,has a an app lock enabled or not and,then it will return true or false and,um,that app is supposed to,show if app locks are installed or not,right but,i have an error right here a 4,4,oo error,and it says session token is invalid,right,and,in this video i want to show you,how easy it actually is to to solve this,problem,and um before we jump in,i,want to,tell you that i'm thinking about i,making a tutorial on how to create this,app right here it's a very very simple,app it's just an app that um will,display or animate the buy button in the,um,in the shopify,storefront,and it's really nothing that much of a,deal but i think if i make a tutorial or,a course about this um about this app,you will learn a lot so if you're,interested in it then uh write it in the,comments and i will start to make a,course on,shopify app development right,so,now to the problem,the problem that we're having is um this,invalid session token and we will get,the session token,from,shopify app bridge you can see it right,here it's a method that you can import,from,shopify average,so you will have to make sure that you,have this mpm package average installed,and if you have that installed then we,can check out how to solve that problem,so let's jump to vs code all right so,you can see my request right here it's,just a regular get request from axios,and in this request um i will,make a call to the uh controller which,will then find out if the app blocks are,enabled or not and then it's going to,return the theme name and it's also,going to return if the app locks are,enabled or not or else it's going to,return an error right so very basic uh,things are going on right here and now i,want to show you how you can,add an interceptor to this call right,here,so the first thing that you will have to,make sure is that you will create an,instance of your app from a bridge and,you're going to do that by,saying const,app,and say use average right so now you,have created an instance of your app,we're going to need that later the next,thing that we will do,is we're going to,create an instance,of axios,because we will need that instance to,add an interceptor to that all right so,we're going to say const,instance,axios,create,where now we want to intercept,all requests on this,axios instance,and we're going to do that by,taking our instance,saying enter,scepters,request,use,and we're going to give it a function,which is going to take the config,and in here,we want to return,get session token,and make sure to import this method get,session token,from,the average utils package right,and this get session token,will need a,an app as a,parameter right,so,that will be a promise,and then we're going to say,thin,and we're going to get that token,now the next thing that we want to do is,we want to take that token and add it to,our request headers,right,so we're going to say config,headers,and add this,as a bearer token,and we're going to use those template,literals,to get this token to add this token to,our,config headers,right and now we can,return,our config,okay,so,now we don't want to make a get request,with a simple axios instance but,we want to create this get request with,this instance that we have added our,interceptors to,right so now we're going to copy this,and say,instance,i'm going to save it,and i need to make sure,i'm going to say npm,run watch,all right so now it has compiled,successfully,and i will go back,to my app,and reload it,and this time i can see that,i will get all of my,all of my data and the request,has successfully worked,right so it was a very small change just,adding this interceptor but you will,have to know that you will need this get,session token and you would also need to,know that you will have to create this,instance of your app from your average,from this um,use average custom hook right but,everything is there and,yeah i hope this worked out for you and,i hope this saved you a little bit of,headache and if you did then please,click the like and subscribe and see you,next time bye

Congratulation! You bave finally finished reading how to not show up on shopify session and believe you bave enougb understending how to not show up on shopify session

Come on and read the rest of the article!

Browse More Content