Question

Invalid Client Error

  • 22 June 2017
  • 4 replies
  • 3151 views

Hi I keep getting the following response:


Authorization: Basic ******************************Content-Type: application/x-www-form-urlencoded;charset=UTF-8Content-Length: 73* upload completely sent off: 73 out of 73 bytes< HTTP/1.1 400 Bad Request* Server nginx/1.10.2 is not blacklisted< Server: nginx/1.10.2< Date: Thu, 22 Jun 2017 10:24:57 GMT< Content-Type: application/json;charset=utf-8< Transfer-Encoding: chunked< Connection: keep-alive< X-Application-Context: application:8080< Content-Language: en< WWW-Authenticate: Bearer realm="RingCentral REST API", error="invalid_client", error_description="Invalid client: "< RCRequestId: 0a67f30c-5735-11e7-a00b-005056bb26b9< AceRoutingKey: sjc11-c01-ace01.c83d65c2-46d3-11e7-ab8e-005056a73f60< X-Server-Name: sjc06-c01-hlb01< X-Request-Time: 0.010< X-Upstream-Server: 10.24.22.193:8080< X-Upstream-Status: 400< X-Upstream-HTime: 0.010< X-Upstream-RTime: 1498127097.763< X-Upstream-CTime: 0.000< X-Tcpinfo: 1000, 500, 10, 28960< RoutingKey: SJC11P01

Here is the snippet I am using to try and authenticate...

 $headers = array(); $headers[] = 'Authorization: Basic 7he87Tb1TjWiy6L7waiCwg'; $headers[] = 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8'; $curl_post_data = 'grant_type=password&username=[sandbox number]&extension=301&password=xxxxxx';     $service_url = 'https://platform.devtest.ringcentral.com/restapi/oauth/token';    $curl = curl_init($service_url);   $fp = fopen('errorlog.txt', 'w'); curl_setopt($curl, CURLOPT_STDERR, $fp); curl_setopt($curl, CURLOPT_VERBOSE, true);    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);    curl_setopt($curl, CURLOPT_POST, true);    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data); $curl_response = curl_exec($curl);    curl_close($curl);    $resp = $curl_response;    $obj = json_decode($resp, true);


Any ideas why I should be getting invalid client??


Thanks


James


4 replies

Hi James,

Please do not expose your credentials while you post anything here!
 
As for the error it looks like your Basic <<Auth Header>> seems wrong ! Please keep in mind, the Authorization would be the form:

Authorization : Basic <<base64 Encode of appKey:appSecret>> 

base64 encode of appKey:  appSecret. You can use https://www.base64encode.org/ to get the base64 encode of appKey followed by a colon (:) followed by an appSecret

You can find your appKey and appSecret under your application in the Developer Portal:
https://developer.ringcentral.com

You could take a look at our Getting Started Help Tutorial here:
https://developer.ringcentral.com/library/getting-started.html

If you are interested in using our Official SDK's, we have an Ringcentral-PHP SDK whihc you could take a look at. Kindly head over to our Github Page:
https://github.com/ringcentral






Hi thanks for getting back to me, I'd forget about the base64... I'm now getting the following error 

"message": "In order to call this API endpoint, application needs to have [Accounts] permission",

when I try to navigate to https://platform.devtest.ringcentral.com/restapi/v1.0/account/

I've added the Read Accounts endpoint but still get the error...

Thanks 

James, what API did you try to call? If you used GET method with this API then "ReadAccounts" should be enough.
My guess is that you use POST by mistake

As Anton said, we can see in your code the following:

curl_post_data

Which clearly indicates you are doing a POST call for an API with GET method which is wrong

Reply