Getting App Bridge session token using plain javascript

Solved
CaveDiver
Tourist
9 0 1

Hi,

Going through the tutorial Get session tokens using App Bridge utilities (shopify.dev).

What would be the ES5 and the CDN-hosted equivalent of this code?

import createApp from "@shopify/app-bridge";
import { getSessionToken } from "@shopify/app-bridge-utils";
const app = createApp({ apiKey: "12345", });
const sessionToken = await getSessionToken(app);

The tutorial Getting started with Shopify App Bridge illustrates the app-bridge part nicely but I'm unclear on the "app-bridge-utils" part.

Thanks

bbarr
Shopify Partner
11 1 1

Bump. This hint of possible ES5 support paired with the lack of documentation is both unprofessional and baffling.

0 Likes
bbarr
Shopify Partner
11 1 1

This is an accepted solution.

@CaveDiverI found it!

On a whim, I tried adding another script based on the naming of their import.

<script src="https://unpkg.com/@shopify/app-bridge-utils@2"></script>
window['app-bridge-utils'].getSessionToken(app).then(token => ...)

 

Shopify's reliance on old-fashioned build tools is short-sighted, and their insistence on marketing-style documentation instead of formal is not helpful.

But at least this is solved

 

CaveDiver
Tourist
9 0 1


@bbarr 

Thanks for the reply. I appreciate it.

0 Likes