php-shopify icon indicating copy to clipboard operation
php-shopify copied to clipboard

Authentication Validation

Open SebastienPoncelet opened this issue 6 years ago • 6 comments

Hello,

I'm currently facing an issue to which I haven't found an answer to, it is related to the authentication.

I do not get any response when I do an authentication, so whether it worked or failed I cannot know until I see bugs later on in my code. That's not so bad while testing but will become quite problematic in operation if I can't detect the success or failure of that step.

Is there any way to actually know if the authentication succeeded and if yes how? Am very new to programming so might have missed something obvious for others here.

Any help would be welcome, thanks.

SebastienPoncelet avatar May 10 '19 09:05 SebastienPoncelet

@SebastienPoncelet I am not sure which authentication you mean. I assume it to be Oauth Authentication. Can you elaborate a bit more, which issue you are facing and in what way you want it to be handled?

tareqtms avatar Jun 11 '19 15:06 tareqtms

@tareqtms Sorry for the delay.

I'm using URL authentication with tokens, trying to use the access token as explained on that page, section "Shopify access token". https://shopify.dev/tutorials/authenticate-a-private-app-with-shopify-admin#make-authenticated-requests

Have tried a few ways to include the access token in the headers but haven't managed it.

How can I include the access token in the header using the SDK?

SebastienPoncelet avatar May 14 '20 07:05 SebastienPoncelet

@SebastienPoncelet It's as simple as this:

$config = array(
    'ShopUrl' => 'yourshop.myshopify.com',
    'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***',
);

$shopify = new PHPShopify\ShopifySDK($config);

Please check the full documentation for the SDK in the README page. It will help a lot!

tareqtms avatar May 15 '20 07:05 tareqtms

Have tried it that way, but it doesn't seem to work. Cannot create a FulfillmentService this way.

SebastienPoncelet avatar May 15 '20 08:05 SebastienPoncelet

Your problem was with authentication. Does the authentication work now?

tareqtms avatar May 15 '20 08:05 tareqtms

Ok, the authentication with the access token does not work in my case. I know that because when I try to create a FulfillmentService, which requires that type of authentication, it does not create it .

When I insert the same access token in Postman's header, with the same json in the request and it creates it. This is why I believe that the authentication as you mentioned does not work.

SebastienPoncelet avatar May 15 '20 08:05 SebastienPoncelet