What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

getSessionToken() returns null in New POS UI Extensions.

getSessionToken() returns null in New POS UI Extensions.

LakshayLakshay
Shopify Partner
11 0 0

Hi,

I am creating an app using the new POS UI Extensions and i want to hit a 3rd party api, after doing some research i got to know i have to create a route in the app backend and then hit that route from UI File ( POS Extension file ) and handle data in req,res manner.

I have create a route in the app backend file ( get - /testpos )

Now for the execution of route from UI File, i need to have a sessionToken with me that i have to send in the header.

For the session token a api is there in the POS UI documentations - https://shopify.dev/docs/api/pos-extensions/ui-extensions-reference/api/session,
upon following every instruction and replacing the entire code with the sample code in the doc, i receive the session Token as Null

IMG_3821.jpg

 

 

L Kalra
Replies 6 (6)

raj02
Shopify Partner
5 0 1

Hey @LakshayLakshay . Any updates on this? I'm facing the same issue of receiving session token as null

LakshayLakshay
Shopify Partner
11 0 0

Hi @raj02 , I reached out to shopify regarding this and the issue was i didnt install the app on the dev store.
Then they added a note to the documentation.

Screenshot 2023-11-09 at 12.58.50.png

Hope this helps.

L Kalra
raj02
Shopify Partner
5 0 1

Thanks for the info @LakshayLakshay but doesn’t solve my issue. I have the app installed. It was working fine until few days back but suddenly faced this issue. 

hakimbd
Visitor
2 0 0

Any update, I'm facing the same issue!

raj02
Shopify Partner
5 0 1

Not sure but was able to repro with one finding, checkout if this helps. Firstly understand the difference between "userId" and "staffMemberId" in context of POS as per this doc. Lets concentrate on "userId" - this is the user who is authenticated on POS i.e. the user account used to log in once you logout from the store on POS. For the user corresponding to this "userID", go to Shopify Admin -> "Settings" -> "Users and permissions" -> Under "staff" check if this user has got the corresponding app permissions through which you are trying to generate the sessionToken.

 

In my case, it worked when I granted the apps permission to the logged in "userId" on POS. Hope this helps

hakimbd
Visitor
2 0 0

I just solved it yesterday, In shopify library the context.php & utils.php I had to do some modifications to make it save the session and after that I needed to remove hashing from shopify access token from the model ( as it is laravel eloquent model ) it automatically hashed it. after more than 10 Hours of debugging it's resolved thanks.