Invalid Client Error

  • 1
  • Question
  • Updated 2 years ago
  • (Edited)
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:< 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 = '';    $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??


Photo of James Williams

James Williams

  • 80 Points 75 badge 2x thumb

Posted 2 years ago

  • 1
Photo of AK

AK, Official Rep

  • 4,412 Points 4k badge 2x thumb
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 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:

You could take a look at our Getting Started Help Tutorial here:

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:
Photo of James Williams

James Williams

  • 80 Points 75 badge 2x thumb
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

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

Photo of Anton Nikitin

Anton Nikitin, Official Rep

  • 3,024 Points 3k badge 2x thumb
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