Skip to main content

I'm getting an "unauthorized_client" error when attempting to send a fax using the PHP API. I have verified that all my parameters are set correctly based on what I see in my app for sandbox. So, I'm not sure what I'm missing. My code is below:

$fax="15136858572";

$RECIPIENT = $fax;

$RINGCENTRAL_CLIENTID = '<client id>';

$RINGCENTRAL_CLIENTSECRET = '<client secret>';

$RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com';


$RINGCENTRAL_USERNAME = '<username>';

$RINGCENTRAL_PASSWORD = '<password>!';

$RINGCENTRAL_EXTENSION = '101';

$rcsdk = new RingCentralSDKSDK($RINGCENTRAL_CLIENTID, $RINGCENTRAL_CLIENTSECRET, $RINGCENTRAL_SERVER);

$platform = $rcsdk->platform();

$platform->login($RINGCENTRAL_USERNAME, $RINGCENTRAL_EXTENSION, $RINGCENTRAL_PASSWORD);


,

I'm getting an "unauthorized_client" error when trying to send a fax through the PHP API. I have my client ID, client secret, server, username, and password all set properly according to the information displayed for my app in sandbox. So, I'm not sure what I'm missing.

Is the username and password correct and from a user under your sandbox account? Can you login the service web site with that user credentials?

If everything is correct, post the app client id here.


I was able to login. The client id is N2eofaCQQ4C85sPt8h8vVg


You app platform type is "Server/Web", which means that you have to implement 3-legged authentication, NOT password flow authentication! See quick start sample code for more details.

If you chose that platform type by mistake and want to change the type to password flow, either create a new app or let me know so I can change the type for you.


I created a new app which took care of the login error. However, now I'm getting an "insufficient permissions" error. I'm guessing I don't have permissions set up properly in the app. All I want to do is send a fax. What am I missing? The client id is Souoo0fTQbOuaQYgnNbQIg


You said all you want to do is to send a fax. Why did you add lots of other permissions?
Read Contacts, Faxes, Read Presence, Contacts, Read Accounts, Edit Extensions, SMS, Internal Messages

What API and how did you call the API?


Selecting all those was just my attempt to get something to work! When I first set it up, I didn't select any permissions and got the error message. So, then I selected Faxes and still got the error message. After that, I just started checking things hoping it would work. At any rate, I went back and changed the permissions back to just Faxes and I didn't get the error!

However, now I have a new problem. For some reason, the fax isn't sending completely. I'm generating and sending a PDF using the following code:

$rcsdk = new RingCentralSDKSDK($RINGCENTRAL_CLIENTID, $RINGCENTRAL_CLIENTSECRET, $RINGCENTRAL_SERVER);

$platform = $rcsdk->platform();

$platform->login($RINGCENTRAL_USERNAME, $RINGCENTRAL_EXTENSION, $RINGCENTRAL_PASSWORD);

$request = $rcsdk->createMultipartBuilder()

->setBody(array(

'to' => array(array('phoneNumber' => $RECIPIENT)),

'faxResolution' => 'High',

))

->add(fopen($path, 'r'))

->request('/account/~/extension/~/fax');

$resp = $platform->sendRequest($request);

print_r ("FAX sent. Message status: " . $resp->json()->messageStatus);

I have verified that the $path variable is pointing to the correct file.


If you receive the cover page but no attachment, it is working. Currently, there is an issue in the sandbox that Fax attachment is not working properly. It works for production though.


Reply