Login Oauth in SuiteCRM 7.10.9

Hi,
I have an external php file , I want to access a module in SuiteCRM using Oauth Login credentials.

I tried this below in code external file.

<?php $instance_url = "http://localhost/SuiteCRM-7.10.9_v1/api/oauth/access_token"; $username = "admin"; $password = "admin"; //Login - POST /oauth2/token $auth_url = $instance_url ;//. "/oauth2/token"; $oauth2_token_arguments = array( "grant_type" => "password", //client id - default is sugar. //It is recommended to create your own in Admin > OAuth Keys "client_id" => "sugar", //"CONSUMER_KEY" => "Test", "client_secret" => "", //"CONSUMER_SECRET" => "Test", "username" => $username, "password" => $password, //platform type - default is base. //It is recommend to change the platform to a custom name such as "custom_api" to avoid authentication conflicts. "platform" => "custom_api" ); $auth_request = curl_init($auth_url); curl_setopt($auth_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_setopt($auth_request, CURLOPT_HEADER, false); curl_setopt($auth_request, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($auth_request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($auth_request, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($auth_request, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //convert arguments to json $json_arguments = json_encode($oauth2_token_arguments); curl_setopt($auth_request, CURLOPT_POSTFIELDS, $json_arguments); //execute request $oauth2_token_response = curl_exec($auth_request); print_r($oauth2_token_response); ?>

My response is:

{“errors”:[{“code”:8000,“title”:"[SuiteCRM] [API] [OAuth] Unable to generate private key",“status”:400},{“id”:“1”,“links”:{“about”:null},“status”:500,“code”:8000,“title”:“JSON API Error”,“detail”:“Api Version: 8”,“source”:{“pointer”:null,“parameter”:null},“meta”:{“about”:“Exception”,“class”:“SuiteCRM\API\v8\Exception\ApiException”,“code”:8000,“langMessage”:null}}],“meta”:{“suiteapi”:{“major”:8,“minor”:0,“patch”:0,“stability”:“ALPHA”}},“jsonapi”:{“version”:“1.0”}

How to solve this?

If I run this URL also http://localhost/SuiteCRM/api/oauth/access_token, I got the response like:

{“errors”:[{“code”:8000,“title”:"[SuiteCRM] [API] [OAuth] Unable to generate private key",“status”:400},{“id”:“1”,“links”:{“about”:null},“status”:500,“code”:8000,“title”:“JSON API Error”,“detail”:“Api Version: 8”,“source”:{“pointer”:null,“parameter”:null},“meta”:{“about”:“Exception”,“class”:“SuiteCRM\API\v8\Exception\ApiException”,“code”:8000,“langMessage”:null}}],“meta”:{“suiteapi”:{“major”:8,“minor”:0,“patch”:0,“stability”:“ALPHA”}},“jsonapi”:{“version”:“1.0”}}

Hi, for a solution look here:

https://suitecrm.com/suitecrm/forum/developer-help/21354-suitecrm-api-oauth-unable-to-generate-private-key#76029