Developers are encountering a TypeError when calling Shopify\Utils::loadCurrentSession() in the PHP API library. The error indicates that the method expects array arguments but receives null values instead.
Core Issue:
The loadCurrentSession() method requires three array parameters: $requestHeaders, $requestCookies, and a boolean flag
Users are passing null or improperly formatted arrays, causing fatal errors
Attempted Solutions:
One user suggested formatting $requestHeaders with api_version and Authorization: Bearer [TOKEN]
Another attempted using X-Shopify-Access-Token header but encountered “Missing Authorization key” errors
Unresolved Questions:
How to obtain an access token from Client ID and Secret ID for private apps installed via distribution links
Difference between Utils::loadCurrentSession() and Context::initialize() methods
Whether access tokens can be retrieved through the Context::initialize() method
New errors emerging around OpenSSL symmetric key requirements
Status: The discussion remains open with no definitive solution. Multiple users report similar authentication/token retrieval challenges when working with Shopify’s private app configuration.
Summarized with AI on November 9.
AI used: claude-sonnet-4-5-20250929.
I have been at this all day, so it’s time to ask for some help!
I am getting the following output when I run the script below, I am sure it’s basic!?! I have looked at permissions, file dir and everything seems ok. Any ideas or suggestions welcome:
[11-Nov-2022 17:09:46 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to Shopify\Utils::loadCurrentSession() must be of the type array, null given, called in /home/############s/apps/discounts/apitest.php on line 27 and defined in /home/############s/apps/discounts/vendor/shopify/shopify-api/src/Utils.php:158
Stack trace:
#0 /home/############s/apps/discounts/apitest.php(27): Shopify\Utils::loadCurrentSession(NULL, NULL, NULL)
#1 /home/############s/apps/discounts/index.php(5): include_once('/home/############...')
#2 {main}
thrown in /home/############s/apps/discounts/vendor/shopify/shopify-api/src/Utils.php on line 158
[11-Nov-2022 17:09:47 UTC] PHP Fatal error: Uncaught TypeError: Argument 1 passed to Shopify\Utils::loadCurrentSession() must be of the type array, null given, called in /home/############s/apps/discounts/apitest.php on line 27 and defined in /home/############s/apps/discounts/vendor/shopify/shopify-api/src/Utils.php:158
Stack trace:
#0 /home/############s/apps/discounts/apitest.php(27): Shopify\Utils::loadCurrentSession(NULL, NULL, NULL)
#1 /home/############s/apps/discounts/index.php(5): include_once('/home/############...')
#2 {main}
thrown in /home/############s/apps/discounts/vendor/shopify/shopify-api/src/Utils.php on line 158
And here’s the script, thanks in advance for any nudge in the right direction!
Gareth
…
Context::initialize(
$_ENV['SHOPIFY_API_KEY'],
$_ENV['SHOPIFY_API_SECRET'],
$_ENV['SHOPIFY_APP_SCOPES'],
$shop_url,
new FileSessionStorage(__DIR__.'/tmp/php_sessions'), // This path works fine - creates dir
'2022-10',
true,
false,
);
use Shopify\Rest\Admin2022_10\PriceRule;
use Shopify\Utils;
$this->test_session = Utils::loadCurrentSession( // Seems to fail here -- see log output
$requestHeaders,
$requestCookies,
$isOnline
);
…
So $requestHeaders must be an array. And so does $requestCookies. Since your code snippet doesn’t show how you create those variables, I can’t help you further.
i can’t send the following request because i don’t have an access token.
To you explain more the problem in give you more details:
First i create a custom application via the partner portal, then i configure the application which allows me to have an ID client and an ID scret.
Then i install the private application in concerned store via distribution link. This means that when creating and configuring the application, I do not have an access token.