SessionToken showing as null

Here’s some code i’m running as a part of a useEffect when my extension is opened:

useEffect(() => {
    const loadData = async () => {
      setIsLoading(true);
      console.log("in here");
      const {shopId, userId, locationId, staffMemberId} = currentSession;
      console.log("shopId:", shopId);
      console.log("userId:", userId);
      console.log("locationId:", locationId);
      console.log("staffMemberId:", staffMemberId);
      const newToken = await getSessionToken();
      console.log("New token:", newToken);

I have this installed as a custom app on a dev store and a merchant store.

on the dev store, newToken gets a JWT
on the merchant store, there are values for all the currentSession properties but newToken stays null.

Any pointers?

thanks!

I would only load this when you are making a API request as otherwise it may expire.
Otherwise you might be hitting this bug

I’m dealing with a similar issue. I have a POS extension with a Modal and Tile and am trying to get a session token in the Modal component but it keeps returning null.

I’m doing something similar to here

What is the right approach to getting the session token?

Same is happening to me. I tried both on Android and IOS on the latest version of the POS app and same issue, the getSessionToken function returns null.

I’m guessing this is related to the POS version since the code worked a few weeks ago. I’m also guessing this is only happening in dev mode since our production app don’t seem affected by this.

Edit: actually seems to be a bit different since it’s working in prod for us but not in dev :sweat_smile:

I believe it’s when the device is idle or wakes. If you retry a few times as suggested here, it should be okay :blush:

Hey folks,

Does retrying as Jordan suggested work?

No this has not worked for me.

I keep retrying and still get null.

I think we have solved it for us. The dev app was not actually installed on the dev store we were testing with. We had launched the app extension through the QR code preview but not actually installed it through the normal OAuth flow