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
Receiving "unauthorized_client" error when using php curl for auth/token
Tags: getting started
Jan 16, 2019 at 3:49am   •   3 replies  •  0 likes
andrew-auger
{    
  "error" : "unauthorized_client",    
  "error_description" : "Unauthorized for this grant type",    
  "errors" : [ {      
    "errorCode" : "OAU-251", 
    "message" : "Unauthorized for this grant type"    
  } ] 
}

Here is my code below:-


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://platform.devtest.ringcentral.com/restapi/oauth/token");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=+12048184079&password=Reset321$$&extension=101&grant_type=password");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "1RjNgM-LTxxxxxFuE-ggrHA" . ":" . "524fjcxxxxxxxxxxCPclIZHxxxxxx_FdfegzA");

$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);

echo '<pre>'; print_r($result); die;

if (curl_errno($ch)) {

echo 'Error:' . curl_error($ch);
}

curl_close ($ch);



3 Answers
answered on Jun 20, 2019 at 12:44am  

The screenshot shared by you seems you have created application of platform type server/ web which supports grant_type=Authorization code while you are trying grant_type=password.

You need to create application that support grant_type,=password or password flow in ring central terms


 0
answered on Jan 16, 2019 at 4:25am  
can you correct my code or give me the exact code according to my php curl for this error


 0
answered on Jan 16, 2019 at 4:08am  
Hi Andrew,

The following grant types are available for your application: 
* Authorization Code
* Refresh Access Token

Please find instructions on how to use these flows:
https://developers.ringcentral.com/api-reference#OAuth-2-0
https://ringcentral-api-docs.readthedocs.io/en/latest/oauth/#authorization-flows

Thanks,
Igor

 1



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