Partkeepr: Problems Setting Up Octopart in v1.2.0

Created on 16 Feb 2017  ·  11Comments  ·  Source: partkeepr/PartKeepr

System Information

  • PartKeepr Version: v1.2.0
  • Reproducible on the demo system: No (as I don't have the ability to modify the configuration on the demo system and Octopart integration appears to be functioning there.)

How to reproduce

I have a very limited understanding of how the Octopart API key gets pushed into the system so I'm making some assumptions as I write this (some of which may be incorrect) so please bear with me. Also, I'll be using 'xxxxxxxx' in lieu of my real Octopart API key in this bug report.

I ran into an issue while attempting to setup Octopart support for my PartKeepr v1.2.0 installation. I started by simply following the instructions in the app/config/parameters.php.dist, which say to set the Octopart API property in the parameters.php file:

$container->setParameter('partkeepr.octopart.apikey', 'xxxxxxxx')`

Doing this seemed to have no effect and didn't enable Octopart support in PartKeepr. Eventually, I went back and ran the web/setup again, which then failed at the "Retrieving Existing Configuration" step with the error message "Invalid Authentication Key." On a whim, I set the partkeepr.octopart.apikey property as follows:

$container->setParameter('partkeepr.octopart.apikey', 'https://octopart.com/api/v3/parts/match?apikey='xxxxxxxx')`

I then reran the web/setup tool and was able to successfully make it past the "Retrieving Existing Configuration" step without any errors and then was able to continue through the rest of the setup process successfully; however, after logging back into PartKeepr, pulling up the detail window for an item and clicking the Octopart button, the Octopart window appeared but was completely empty (note there were no error messages displayed in the UI.) A quick look at the partkeepr.log showed the following error:

request.CRITICAL: Uncaught PHP Exception Guzzle\Http\Exception\ClientErrorResponseException: "Client error response [status code] 401 [reason phrase] Unauthorized [url] http://octopart.com/api/v3/parts/search?apikey=https%3A%2F%2Foctopart.com%2Fapi%2Fv3%2Fparts%2Fmatch%3Fapikey%3Dxxxxxxxx&q=STD950BLK&start=0&include%5B0%5D=short_description&include%5B1%5D=specs&include%5B2%5D=datasheets&limit=20" at /var/www/partkeepr.domain.com/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php line 43 {"exception":"[object] (Guzzle\\Http\\Exception\\ClientErrorResponseException(code: 0): Client error response\n[status code] 401\n[reason phrase] Unauthorized\n[url] http://octopart.com/api/v3/parts/search?apikey=https%3A%2F%2Foctopart.com%2Fapi%2Fv3%2Fparts%2Fmatch%3Fapikey%3Dxxxxxxxx&q=STD950BLK&start=0&include%5B0%5D=short_description&include%5B1%5D=specs&include%5B2%5D=datasheets&limit=20 at /var/www/partkeepr.domain.com/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43)"} []

From the log message above, the problem appears to be an issue with the web/setup's apikey verification/validation. It would seem that process needs the full Octopart URL endpoint (with the apikey included as a URL parameter) in order to be validated; however, PartKeepr itself only wants the standalone apikey string specified at runtime for substitution, which makes sense as the URL for the API is specified in the const OCTOPART_ENDPOINT in /src/PartKeepr/OctoPartBundle/Services/OctoPartService.php.

The workaround for this (at least the one I used for the time being) is to leave the full Octopart API endpoint (with the API key included as a URL parameter) in the parameters.php for the setup process, which seems to need to complete successfully in order to convince PartKeepr that Octopart support is enabled. Then I modified the /src/PartKeepr/OctoPartBundle/Services/OctoPartService.php file by assigning the apiKey to a string literal, representing my Octopart API key (as shown below):

public function __construct($apiKey) { $this->apiKey = "xxxxxxxx"; }

I think the fix for this is to correct the validation of the API key in the web/setup utility but I'm not sure. My apologies if I've misunderstood something or how this process all works.

Cheers!

Most helpful comment

Hi!
I had problem with Octopart integration to. I inserted my API key in parameters,php, ran setupa again, but the Octopart search steal didn't work. So i folowed @tracklogic 's advice and delted the cache :
sudo rm -rf app/cache/*
Then I ran the setup again, and everything now works!

All 11 comments

As several people setup the OctoPart integration I don't believe the implementation is wrong, but rather your API key.

I think I know what the problem is.

Setup does not verify the OctoPart API key. Which lead you to the assumption you would need to enter the full OctoPart URI instead of the key itself, which then causes an error retrieving the data.

Invalid Authentication Key is displayed if the key in app/authkey.php is not equal to what you entered.

I had problems installing Octopart too.
What i did is re-run Setup process (after API key has been saved). Then Octopart search worked as intended.

I've done this before... it stores the OctoPart key (or lack of it) somewhere in the cache directory - i just deleted the cache folder and refreshed PartKeepr and it picked up that i'd now specified an OctoPart key - bit of headscratching for a while though as it was telling me I'd not specified one in parameters.php when i had!

@WickedAx can you provide additional feedback?

No feedback given, closing

No feedback given for an extended period of time, closing the issue.

Feel free to re-open if you have additional information.

Hi!
I had problem with Octopart integration to. I inserted my API key in parameters,php, ran setupa again, but the Octopart search steal didn't work. So i folowed @tracklogic 's advice and delted the cache :
sudo rm -rf app/cache/*
Then I ran the setup again, and everything now works!

Same issue, deleting the cache as mentioned already did the trick.

I have tried the tricks above, deleting the cache and running setup again.
I think my issue is with my octopart API key, Octopart has the API key listed next to text that says

Your request for an Octopart API key is being reviewed.

It feels strange to me to issue a inactive API key, hopefully this is the issue I am having.
It would be good to have some technique or better error message informing on why the API call has failed.

Is there any way to turn on debugging or any other log files other than the apache logs?

@lhovo The comment also states that you have to contact [email protected] if you have questions. For example; if its under review for far too long; contact them. It won't work until it's no longer under review.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gfarcas picture gfarcas  ·  20Comments

dani2bunny picture dani2bunny  ·  24Comments

kgabryszewska picture kgabryszewska  ·  8Comments

FinalHopee picture FinalHopee  ·  32Comments

Gasman2014 picture Gasman2014  ·  26Comments