News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Fatal error: Uncaught exception 'Exception' with message 'Response has unsuccessful status' and "Unauthorized for this grant type"
Tags: sdk
Jun 29, 2016 at 8:06am   •   5 replies  •  0 likes
hassan-shahzad

Facing this fatal error Response has unsuccessful status


use RingCentral\SDK\Http\HttpException;
use RingCentral\Http\Response;
use RingCentral\SDK\SDK;

require_once(__DIR__ . '/vendor/ autoload.php');

$rcsdk = new SDK('******', '*****', ' https://platform.devtest.ringcentral.com', 'Demo', '1.0.0');
$platform = $rcsdk->platform();
$auth = $platform->login('+12679304066', '101', '*******');
// Load something nonexistent
echo 'login response:' . $auth->text(). PHP_EOL;

installed via composer curl is enabled and also added i php.ini

curl.cainfo = "E:/wamp/cacert.pem" after downloading pem file.

5 Answers
answered on Jan 20, 2021 at 3:04am  

I get error Fatal error: Uncaught Exception: Response has unsuccessful status in C:\xampp3\htdocs\ringcentral\vendor\ringcentral\ringcentral-php\src\Http\Client.php:44 Stack trace: #0 C:\xampp3\htdocs\ringcentral\vendor\ringcentral\ringcentral-php\src\Platform\Platform.php(310): RingCentral\SDK\Http\Client->send(Object(GuzzleHttp\Psr7\Request)) #1 C:\xampp3\htdocs\ringcentral\vendor\ringcentral\ringcentral-php\src\Platform\Platform.php(434): RingCentral\SDK\Platform\Platform->sendRequest(Object(GuzzleHttp\Psr7\Request), Array) #2 C:\xampp3\htdocs\ringcentral\vendor\ringcentral\ringcentral-php\src\Platform\Platform.php(212): RingCentral\SDK\Platform\Platform->requestToken('/restapi/oauth/...', Array) #3 C:\xampp3\htdocs\ringcentral\index.php(16): RingCentral\SDK\Platform\Platform->login(Array, '101', 'XXXXXXXXX') #4 {main} Next RingCentral\SDK\Http\ApiException: Unauthorized for this grant type in C:\xampp3\htdocs\ringcentral\vendor\ringcentral\ringcentral-php\src\Http\Client.php:52 Stack trace: #0 C:\xampp3\htdocs\ringcentral\ve in C:\xampp3\htdocs\ringcentral\vendor\ringcentral\ringcentral-php\src\Http\Client.php on line 52


 0
on Jan 20, 2021 at 7:30am   •  0 likes

You have to provide better background info. Just those traces do not help me help you.

- Some code where you implement login

- Platform environment (sandbox or production)

- App client id or authentication grant type

Also, check and clean your traces before posting to avoid posting sensitive information. I have to edit your question to XXX out your login password!

answered on Jul 2, 2019 at 11:43pm  

If you're using an OAuth 2.0 request using the OAuth 2.0 you need to provide the correct grant_type while making a call

Please note, application created with different platform type will have different grant_type.

If your application is public then most of the case the grant_type will be Authorization code where you need to login using your user ID and password. It will be launching a browser window to make a call to an authorization URL implementing a 3-legged (Authorization Flow) auth in you PHP code. Also for the issue you are facing, you also need to check the SSL certificate you are using.

RingCentral JavaScript SDK has methods to handle the authorization code grant flows.


 0
answered on Jun 23, 2019 at 4:10am  

If you're using an OAuth 2.0 request using the OAuth 2.0 you need to provide the correct grant_type while making a call

Please note, application created with different platform type will have different grant_type.

If your application is public then most of the case the grant_type will be Authorization code where you need to login using your user ID and password. It will be launching a browser window to make a call to an authorization URL implementing a 3-legged (Authorization Flow) auth in you PHP code. Also for the issue you are facing, you also need to check the SSL certificate you are using.

RingCentral JavaScript SDK has methods to handle the authorization code grant flows.


 0
answered on Jun 30, 2016 at 11:17am  
Hi Hassan,

The reason you are getting that error is because your application is of type "Public" and we make sure that all the RingCentral Applications of type Public implement the  Authorization Code Flow mandatorily.

Kindly take a look at our demo in PHP here :
https://github.com/grokify/ringcentral-demos-oauth/tree/master/php

For further information on Authorization Flow, please refer to our documentation here :
https://developer.ringcentral.com/api-docs/latest/index.html#!#AuthorizationCodeFlow

Let us know if you are able to get it working. Thanks.

 0
answered on Jun 30, 2016 at 5:19am  
Ak,
I had already go through this link and resolve this error by second method you specify, after that i am facing this error attached in my issue.
I follow your first step Within the SDK but even then this issue exists.
please help


 0
answered on Jun 29, 2016 at 6:01pm  
Hi Hassan,

If you are using custom SSL Certificates you could adopt the following methods to set the path to the PEM file :

1.) Within the SDK

This option would require modifying the SDK the Cient.php code. When using this approach, ideally the path parameter could be passed into the SDK.

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);  curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem");    

 2.)  using the php.ini file
You would have to add this to the php.ini file :
curl.cainfo=/path/to/cacert.pem 
For more detailed information Refer to this in our Github-PHP-SDK-Issue

Could you verify if the certificate is valid if you are using the option 2 specified above

 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us