Issue with using graphql and php library

Topic summary

A developer is building a headless PHP application to sync product stock levels via a cron job but is encountering authentication issues with Shopify’s GraphQL PHP library.

Main Problem:

  • The library documentation suggests using Auth0 for session tokens, which seems unnecessary for a headless/automated application
  • Direct API requests to the GraphQL endpoint (with X-Shopify-Access-Token header) fail with “cURL error 6: Could not resolve host: login”
  • Browser access to the endpoint prompts for username/password instead of accepting the access token

Current Status:

  • One respondent confirmed that Shopify’s PHP SDK is primarily designed for OAuth browser-based flows
  • Suggested workaround: Use Context::initialize() method to configure the SDK for headless usage
  • The issue remains unresolved; no confirmation yet whether the suggested approach works
Summarized with AI on October 30. AI used: claude-sonnet-4-5-20250929.

I’m trying to create a simple app that reads our stores products, contacts an external API to get stock levels then update our stores products with the new stock levels how ever encountering alot of issues..

The examples for the graphQL library for php seems to be a bit strange, says i need to authenticate my app using auth0 which will give me a session token and allow me to query then my shopify store using graphQL however that seems strange to me?

This app will be completely headless.. will be run on a cron job so why would i need to authenticate? Isn’t that what my stores api key and access token is for?

Anyway i tried to then make a request to my store https://XXXXXX/admin/api/2025-01/graphql.json

with the X-Shopify-Access-Token in the headers and i get a curl error " cURL error 6: Could not resolve host: login"

if i try visit that url in my browser a login box prompts for a username and password?

Any help would be appreciated, thanks.

Shopify’s PHP SDK is unfortunately geared toward regular Oauth (browser) users. You can use Context::initialize() to get things started for headless usage.