Closed robjenman closed 2 years ago
This morning I've seen that buried in your documentations here on Github (Versus not shown in any example on the API reference) is that this is targeted at Partner Apps and not consuming the API as a private app despite that being what is shown on the API reference pages.
As it wouldn't have a app key or secret you can't initialise and this can't be used.
Hi @Chutney, in order to make any requests to the Admin API you'll need to call Context::initialize
, even if you're using a private app. You can see all of the parameters at https://github.com/Shopify/shopify-php-api/blob/main/docs/getting_started.md, and you'll need to set:
apiKey
: your private app's API keyapiSecretKey
: your private app's passwordisPrivateApp
: trueYou can see your private app's settings in your Admin:
Apps
Manage private apps
under the app listAPI key
and password
I'll update the documentation to make it easier to see how to use the api key and password for private apps, thank you for raising this!
Yes, this is quite a major problem for what seems to be the official Shopify Library, and I'd like to request updated documentation as well.
The getting started page doesn't mention private app set up at all.
It seems to imply that there's a long list of parameters to pass as an array to the initialize method, but then the example shows them as arguments instead of parameters. It is not clear which to make. Normally initialize methods take arrays, but this seems not to.
The documentation implies that a session manager object is needed to connect to a private app, using oAuth. In fact, rest calls can be made with normal token/url for private apps. This could be made clearer.
+1
Are there any updates regarding this issue?
This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.
We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines
Thank you!
I have the same problem
hey guys,
Call the Context::initialize static function, you will need KEY, SECRET, SCOPES, SHOP NAME and a FileStorageSession. The first 3 you get from the dev app created on your shopify dashboard.
As example
Context::initialize( getenv('SHOP_APP_KEY'), getenv('SHOP_APP_SECRET'), 'read_customers, read_discounts, read_discovery, read_draft_orders, read_assigned_fulfillment_orders, read_merchant_managed_fulfillment_orders, read_order_edits, read_orders, write_orders, read_third_party_fulfillment_orders, read_order_submission_rules', getenv('SHOP_APP_NAME'), new FileSessionStorage('/tmp/php_sessions') );
Run the initialize before your Rest api calls.
So if you only get the shop name and access token, which is the only data actually necessary to make a query, you can't use this library for no valid reason?
So if you only get the shop name and access token, which is the only data actually necessary to make a query, you can't use this library for no valid reason?
same problem. makes no sense to me
@conradfr
You can do this ugly workaround
Context::$HTTP_CLIENT_FACTORY = new HttpClientFactory;
$client = new Graphql(...,...);
Issue summary
Error thrown: Call to a member function client() on null in /var/www/vendor/shopify/shopify-api/src/Clients/Http.php on line 164
Expected behavior
$client = Context::$HTTP_CLIENT_FACTORY->client();
Should be returning a working Guzzle client however it isnt. Apologies it's late here butContext::initialize()
is never called as far as I can see and so$HTTP_CLIENT_FACTORY
is never populated with the Guzzle client that is relied on.Steps to reproduce the problem
new \Shopify\Clients\Rest($url, $accessToken)->get('orders');