Jump to content
formulate

wireHTTP API authorization issue

Recommended Posts

I'm at the end of my rope! I've been trying to use a 3rd party API that requires authorization. I've tried a zillion different ways in both cURL and wireHTTP. cURL always tells me the signature is wrong. wireHTTP returns 401 unauthorized.

Here's the brief documentation for authorization with the API: https://integrate.spektrix.com/docs/authentication

Here's the latest version of my wireHTTP code:

$date = date(DATE_RFC1123);
$string = "GET\n/sidwilliams/api/v3/customers/I-KS22-363P/\n$date";
$string = utf8_encode($string);
$key = base64_decode('XXXX');
$signature = base64_encode(hash_hmac('sha1', $string, $key)); 

$http = new WireHttp();
$http->setHeader('Host', 'system.spektrix.com');
$http->setHeader('Date', $date);
$http->setHeader('Authorization', 'SpektrixAPI3 website:' . $signature);
$response = $http->get('https://system.spektrix.com/sidwilliams/api/v3/customers/I-KS22-363P/'); 

if($response === false) {
    echo $http->getError(); 
}else{
	echo $response;
}

If anyone is interested in seeing my cURL, I can post that too.

Thanks!

Share this post


Link to post
Share on other sites

Have you tried with the $raw_output parameter for hash_hmac? And just to make sure: you use your real spektrix username in place of "website" in setHeader, right?

Share this post


Link to post
Share on other sites

Yes I've tried it with and without $raw_output.

'website' really is the API username.

Share this post


Link to post
Share on other sites

@formulate Did you get Spektrix API working? I am having hard time integrating it. Having the same issue you faced! Can you please help, thanks;

Share this post


Link to post
Share on other sites

I did get it working! It took A LOT of time and money, but I eventually got it working. Their documentation is A) terrible and even B) misleading. I'll shoot you a message and we can pick this up in email (it'll be easier that way).

Share this post


Link to post
Share on other sites
15 minutes ago, formulate said:

I did get it working! It took A LOT of time and money, but I eventually got it working. Their documentation is A) terrible and even B) misleading. I'll shoot you a message and we can pick this up in email (it'll be easier that way).

Thank you so much!! you rock

Share this post


Link to post
Share on other sites
15 hours ago, formulate said:

I'll shoot you a message and we can pick this up in email (it'll be easier that way).

But it will not help others that may have the same problem in the future 😉 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...