Official PHP Client Library Authentication code

Topic summary

Problem: Developers are unable to authenticate using Shopify’s official PHP client library to create a session, despite having REST/cURL access working for a private app.

What was tried:

  • Example code using Shopify\Utils::loadCurrentSession($headers, $cookies, $isOnline) followed by instantiating Shopify\Clients\Rest. Errors arise because required variables/headers are undefined.
  • Another attempt passed headers including api_version and X-Shopify-Access-Token with empty cookies and isOnline = true. loadCurrentSession returns “Missing Authorization key in headers.”

Key details:

  • loadCurrentSession expects specific request headers/cookies to reconstruct a session; the error indicates an Authorization header is required. Precise header format or a working example wasn’t provided in the thread.
  • Code snippets are central to understanding the issue.

Status and outcomes:

  • No working sample code or solution was shared.
  • Multiple participants asked if a fix was found; the discussion remains unresolved with unanswered questions about the correct authentication flow and required headers when using the PHP client library.
Summarized with AI on January 13. AI used: gpt-5.

I have a partner account and created a store to do some testing. Made a private app, generated the necessary keys etc to get started. I know how to use the REST requests together with curl and it works fine. But now I’d like to use the (official) PHP client library, which I installed with composer. I find alot of tutorials and explanations about authentication, but it seems hard to find actual sample code on how to do this. This is what I have so far (I found this online), but of course it returns errors about vars not found (cfr headers and such).

include('vendor/autoload.php');
use Shopify\Clients\Rest;
$session = Shopify\Utils::loadCurrentSession($headers, $cookies, $isOnline);
$client = new Rest($session->getShop(), $session->getAccessToken());
$response = $client->get('shop');

Once authenticated I’ll know my way around; but I don’t seem to get beyond this point …
Any sample code with (fake) credentials and such would be much appreciated.
Thnx in advance.

Did you found how ?

I’m currently stuck with

$requestHeaders = array(
‘api_version’ => ‘2023-04’,
‘X-Shopify-Access-Token’ => $accessToken
);

$requestCookies = array();
$isOnline = true;

$session = Shopify\Utils::loadCurrentSession(
$requestHeaders,
$requestCookies,
$isOnline
);

returning Missing Authorization key in headers

Did you able to find how it is doing?