question

Vascular Access On Demand avatar image
Vascular Access On Demand asked Phong Vu commented

Getting "unauthorized_client" error,Getting unauthorized_client Error

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 \RingCentral\SDK\SDK($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.

authentication
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered

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.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Vascular Access On Demand avatar image
Vascular Access On Demand answered Phong Vu commented

I was able to login. The client id is N2eofaCQQ4C85sPt8h8vVg

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

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.

0 Likes 0 ·
Vascular Access On Demand avatar image
Vascular Access On Demand answered Phong Vu edited

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

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

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?

0 Likes 0 ·
Vascular Access On Demand avatar image
Vascular Access On Demand answered Phong Vu commented

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 \RingCentral\SDK\SDK($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.

3 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

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.

0 Likes 0 ·
Vascular Access On Demand avatar image Vascular Access On Demand Phong Vu ♦♦ commented ·

I did indeed get a cover page. So, how do I move the app into production? I see the graduation requirements but am not completely sure how they work. Yesterday, the Exercise all requested permission was green. Now it's red. Do I just have to keep sending faxes in sandbox until all three are green?


Thanks!

Floyd

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Vascular Access On Demand commented ·

Yes, the API calls need to be within 2 days.

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys