diff --git a/src/Http/Middleware/VerifyShopify.php b/src/Http/Middleware/VerifyShopify.php index f2f29cd7..ea6e0531 100644 --- a/src/Http/Middleware/VerifyShopify.php +++ b/src/Http/Middleware/VerifyShopify.php @@ -387,10 +387,10 @@ protected function getAccessTokenFromRequest(Request $request): ?string return $newestToken; } - return $request->get('token'); + return $request->get('id_token'); } - return $this->isApiRequest($request) ? $request->bearerToken() : $request->get('token'); + return $this->isApiRequest($request) ? $request->bearerToken() : $request->get('id_token'); } /** diff --git a/src/resources/views/auth/token.blade.php b/src/resources/views/auth/token.blade.php index 8433d57f..795bc5ba 100644 --- a/src/resources/views/auth/token.blade.php +++ b/src/resources/views/auth/token.blade.php @@ -37,9 +37,30 @@ @if(config('shopify-app.appbridge_enabled')) @endif diff --git a/src/resources/views/layouts/default.blade.php b/src/resources/views/layouts/default.blade.php index 313e2bfd..741f92c4 100644 --- a/src/resources/views/layouts/default.blade.php +++ b/src/resources/views/layouts/default.blade.php @@ -1,44 +1,31 @@ - - - + + + - {{ \Osiset\ShopifyApp\Util::getShopifyConfig('app_name') }} - @yield('styles') - + {{ \Osiset\ShopifyApp\Util::getShopifyConfig('app_name') }} - -
-
-
- @yield('content') -
-
-
+ + - @if(\Osiset\ShopifyApp\Util::getShopifyConfig('appbridge_enabled') && \Osiset\ShopifyApp\Util::useNativeAppBridge()) - - + @yield('styles') + - @include('shopify-app::partials.token_handler') - @include('shopify-app::partials.flash_messages') - @endif + +
+
+
+ @yield('content') +
+
+
- @yield('scripts') - +@if(\Osiset\ShopifyApp\Util::getShopifyConfig('appbridge_enabled') && \Osiset\ShopifyApp\Util::useNativeAppBridge()) + @include('shopify-app::partials.token_handler') +@endif + +@yield('scripts') + diff --git a/src/resources/views/partials/token_handler.blade.php b/src/resources/views/partials/token_handler.blade.php index a13efaf6..692f99c2 100644 --- a/src/resources/views/partials/token_handler.blade.php +++ b/src/resources/views/partials/token_handler.blade.php @@ -4,13 +4,13 @@ // Token updates document.addEventListener(LOAD_EVENT, () => { - retrieveToken(app); - keepRetrievingToken(app); + retrieveToken(shopify); + keepRetrievingToken(shopify); }); // Retrieve session token async function retrieveToken(app) { - window.sessionToken = await utils.getSessionToken(app); + window.sessionToken = await app.idToken(); // Update everything with the session-token class Array.from(document.getElementsByClassName('session-token')).forEach((el) => {