SwitchBotAPI icon indicating copy to clipboard operation
SwitchBotAPI copied to clipboard

Unauthorized while using API v1.1

Open agneskang opened this issue 2 years ago • 0 comments

Current Situation

I try to use API v1.1, but got "Unauthorized". My testing headers of authorization:

Array ( [0] => Content-Type: application/json; charset=utf8 [1] => Authorization: 47583bd753984b5abfb58bb7107fd5ab [2] => sign: pcDLso9GX9oDrQJu+Iv973G14tRwa7O0xkKIvbt4FmI= [3] => nonce: 5907 [4] => t: 1669625340000 )

My PHP code for generating "sign": $thistime = intval(round(time()*1000 )); $nonce = rand(1000,9999); $str_to_sign = $this->api_token.$thistime.$nonce; $thiskey = $this->api_key; $sign = hash_hmac('sha256', $str_to_sign, $thiskey , true ); $sign = base64_encode($sign);

Please help me to figure out the problem why not passing through the authorization.

Logs

=====請求返回=====
out headers:	
header len:	273
httpcode:	401

===================
 [message] => Unauthorized

Configuration

php 7.3
switchbot opens-i v1.1

Environment

  • OS:linux
  • Software:php 7.3
  • Node:
  • npm:

Additional Context

No response

agneskang avatar Nov 28 '22 09:11 agneskang