Shopify App bridge Session token with php authentication

eluminous_anis
Visitor
1 0 1

Please help me to authenticate Shopify app bridge session token with php shopify library.

 

https://github.com/Shopify/shopify-php-api/blob/main/docs/getting_started.md

 

<script>
var shopUrl = 'https://xyz.myshopify.com';
var AppBridge = window['app-bridge'];
var appBrdigeUtils = window['app-bridge-utils'];
var getSessionToken = appBrdigeUtils.getSessionToken;
var createApp = AppBridge.default;
var app = createApp({
apiKey: '123456',
host: 'abcxyz',
forceRedirect: true,
});
 
document.addEventListener("DOMContentLoaded"async function () {
// Wait for a session token before trying to load an authenticated page
await retrieveToken(window.app);

// Keep retrieving a session token periodically
keepRetrievingToken(window.app);

async function retrieveToken(app) {
window.sessionToken = await getSessionToken(app);
$.ajaxSetup({
headers: {
'Authorization'"Bearer " + window.sessionToken
}
});
}

function keepRetrievingToken(app) {
setInterval(function () {
retrieveToken(app);
}, SESSION_TOKEN_REFRESH_INTERVAL);
}
});
</script>
 
I added this script but unable to authenticate with php library.
Reply 1 (1)

Skylitech
Shopify Partner
9 0 5

Can you please share the full code after the header creation?