php-shopify
php-shopify copied to clipboard
GraphGL throws exception for private app authentification
Prerequisite: we want to write a non public "private app"
The exception in HttpRequestGraphQL.php:44 is triggered if you try to use a graphql qery with a the usual private app's credentials.
throw new SdkException("The GraphQL Admin API requires an access token for making authenticated requests!");
For private apps here is no access token required, it will work with the usual basic auth credentials, so the exception is wrong in that case.
The call will work (for private apps) as expected when you just comment out the exception. (HttpRequestGraphQL.php:44) This should not be nessacary. We might need way to declare/check if we are working with a private or a public app.
The proper headers are not being sent to Shopify. Make sure to add AccessToken into your config. The AccessToken is the same as your password. Your GraphQL calls will go through then.
` $config = array( 'ShopUrl' => 'xxx1', 'ApiKey' => 'xxx2', 'Password' => 'xxx3', 'AccessToken' => 'xxx3', );
$shopify = new PHPShopify\ShopifySDK($config);
//$fields_array is the post data you are sending $result = $product = $shopify->GraphQL->post($query, null, false, $variables); print $result; `
Very good,
This is helpful to me.
Thanks.