adobe / stock-api-libphp

PHP implementation of the Stock APIs
Apache License 2.0
18 stars 20 forks source link

WooCommerce error #19

Open marypieroszkiewicz opened 4 years ago

marypieroszkiewicz commented 4 years ago

Hi. I have a problem with the Stock API libphp on the site where the WooCommerce store is on Wordpress. There is such an error in the log:

Fatal error: Uncaught Exception: Client error: GET https://stock.adobe.io/Rest/Media/1/Search/Files?locale=pl_PL&search_parameters%5Bmedia_id%5D=171086334&search_parameters%5Blimit%5D=32&search_parameters%5Boffset%5D=0 resulted in a 401 Unauthorized response: {"error_code":"401013","message":"Oauth token is not valid"}

in /home/midgart2/ftp/tapeko.pl/wp-content/themes/tapeko/vendor/astock/stock-api-libphp/src/Exception/StockApi.php on line 34

Website: https://tapeko.pl/produkt/fototapety/40957985/

Thank you for help.

chfabbro commented 4 years ago

Hi Mary. Did you build the WooCommerce integration, or are you only using it? Adobe did not build the integration, but we did build the SDK.

The error you see is caused by a missing or invalid authentication token. In other words, you would need to sign into an Adobe service and the integration would need to use your access token. If you never signed in or if the token is expired or invalid, then you would get this error.

If you have not been made to sign into Stock, then this is likely a bug in the integration. FYI it is not necessary to sign in to use the Search API. The SDK allows you set the access token to null and it will use an unauthenticated search. If you are not the developer of this integration, then this should be opened as a bug for that team. Do you know if they have a GitHub project for their WooCommerce plugin?

marypieroszkiewicz commented 4 years ago

Hello Christopher. Thank you for answer.

I didn't build anything, I got a website where an error pops up ... probably the website uses only SDK.

The website uses "Advanced Custom Field" where Adobe Stock photos are added to the collection.

In the console for this website, I created OAuth Web for this website

Screen: https://i.imgur.com/kSCVB2L.png

I added the generated OAuth to the AdobeConfig.php configuration file

Screen: https://i.imgur.com/iLjbdFV.png

and the error is still there. What should I do next so that the error does not appear. Thank you for your help.

chfabbro commented 4 years ago

Hi Mary,

I recommend you start by looking at the OAuth workflow guide here: https://github.com/adobe/stock-api-docs/blob/master/supplemental/Stock-Authorization-Code-Workflow.pdf

And also the sample code I created here: https://github.com/adobe/stock-api-samples/tree/master/php/authcode-php

The configuration looks okay, but keep in the mind the SDK does not perform authentication. It assumes that you will be authenticating and creating an access token outside of the SDK. Adobe Stock is just one service, but authentication is provided by the Adobe IMS identity services, and must be integrated separately. My sample code shows you how to do that using only PHP and some open source libraries. Once you authorize and have a valid token, then the SDK is used with that token.

If you have further questions, it would be more efficient if you emailed them to stockapis@adobe.com, which is a mail list that I manage.