#known 2017-08-19

2017-08-19 UTC
[miklb], tantek, [colinwalker], jeremycherfas, raretrack and loicm joined the channel
#
jeremycherfas
If I want to use the API to add a bookmark, do I need to create the signature using /status/bookmark/edit or bookmark/edit or something else?
#
jeremycherfas
I don’t see any difference in the URL when I am on the New Bookmark page.
#
mapkyca
It'll be /like/edit for bookmarks
loicm joined the channel
#
jeremycherfas
Sent you a reply, but as you’re here …
#
mapkyca
Check your logs, there should be some debug that might hint at where the calculation is failing
#
jeremycherfas
Known logs, or other?
#
jeremycherfas
Hang on. Should I be running that command to calculate the signature from the Known directory?
#
mapkyca
Shouldn't matter if you're calling the api
#
mapkyca
this has some working examples which might help: http://docs.withknown.com/en/latest/developers/plugins/api/
#
jeremycherfas
No, I’m talking about calculating the signature from my API and the URL
#
jeremycherfas
I looked at that, and I’m still trying to get hold of a value to -plug into X-KNOWN-SIGNATURE to poke around before I go to PHP.
#
jeremycherfas
I’m trying to usie a Restlet client in Chrome to poke around and see what’s possible.
#
mapkyca
Aye, X-KNOWN-SIGNATURE is a HMAC formed over the action and your user specific api key. There's a php example for how to generate these, but also a shell example in the curl examples...
#
jeremycherfas
I thought I could generate it in Terminal. That’s a bit of a problem. No matter. What is the signed HTML authorization? I tried my usual username:Ppw combination but that didn’t work. Can I use something like that?
#
jeremycherfas
Sorry to be a pain
#
mapkyca
You can generate it in your terminal, assuming you've got openssl installed, or even php-cli, in order to generate the sha256 hmac. The api key is available from yoursite.com/account/settings/tools/
#
jeremycherfas
That is what I was trying to do, and that seems to be what was giving the error!
#
jeremycherfas
Using this command Jeremys-iMac:~ jeremycherfas$ HMAC=$(echo -n "/status/edit" | openssl dgst -binary -sha256 -hmac 'MY-API' | base64 -w0)
#
jeremycherfas
With my API, obviously, I get this error base64: invalid option -- w
#
mapkyca
the w option disables line wrapping, may not be available on your version ...
#
jeremycherfas
OK. I’ll try without
#
mapkyca
you could also try using PHP CLI
#
mapkyca
something like:
#
mapkyca
export HMAC=$(echo '<?= base64_encode(hash_hmac("sha256", "/like/edit", "APIKEY", true)); ?>' | php)
#
jeremycherfas
Just finishing something else.
#
jeremycherfas
Yes! I managed to send a GET and receive a reply.
#
jeremycherfas
Mapkyca++ for assistance
#
Loqi
mapkyca has 10 karma in this channel (17 overall)
#
mapkyca
Glad you got it working! :)
#
jeremycherfas
Spoke too soon. I saw a response and thought I was there, but in fact I am getting a 403 Forbidden.
#
jeremycherfas
Going to give up now though. I’ve been at it too long.
#
jeremycherfas
Thanks in any case.
#
jeremycherfas
One final question: How many characters long is the HMAC supposed to be?
#
mapkyca
base64 encoded it'll come out at 44 chars
[chrisaldrich] and travis-ci joined the channel
#
travis-ci
idno/Known#4072 (master - 1cf35a5 : Marcus Povey): The build has errored.
[kevinmarks] and tantek joined the channel
#
mapkyca
Again, check your logs. You're getting 403 because of an error in the hmac. The logs should give you some hints as to what is being miscalculated.