Closed connor11528 closed 6 years ago
Try excluding the ACCESS_TOKEN
field from the constructor. The access token is only returned after the store has given your app permission (unless you have it stored somewhere already).
$shopify = \App::make('ShopifyAPI', [
'API_KEY' => 'eb2c00e.....a2d3',
'API_SECRET' => 'f5f07f1bdf1.......0a2f5112', // listed as Shared secret in shopify console
'SHOP_DOMAIN' => 'employbl.myshopify.com', // Remove trailing '/'
]);
You will also need to run $shopify->installURL()
(see README for example) to obtain the authorization link to allow the user to login and grant permission to your app.
$authorization_uri = $shopify->installURL([
'permissions' => array('write_orders', 'write_products'),
'redirect' => 'http://myapp/success' // update this to where Shopify should redirect the user
]);
echo sprintf('<a href=\'%s\'>Shopify Login</a>', $authorization_uri);
This link will direct you to login to Shopify and grant your app permission to the store, and then redirect to the URL specified in the installURL()
parameter. From there, you should perform validations on hmac and then obtain the access code, which will allow you to make API requests.
I have a function where I would like to connect to my shopify app. I am following this tutorial
I send a POST request from the client side to authenticate my app to use shopify data. I currently have my data values hardcoded in order to connect to the API
When I run this code I get an error of 400 bad request. If I swap the values in API_SECRET and ACCESS_TOKEN I also get the bad request error.
What am I doing wrong in my request formatting and how can I connect to the shopify API?
Full error output: