php - google predicate API Refresh token exception -


i have use google predicate api project m playing "hello prediction" sample first https://developers.google.com/prediction/docs/hello_world

i want use service account auth method in order call api directly web server

here script,

google_authexception object (     [message:protected] => error refreshing oauth2 token, message: '{   "error" : "invalid_grant" } 

any suggestions?

            <?php             ini_set('display_errors',1);             error_reporting(e_all);              require_once 'google-api-php-client/google_client.php';             require_once 'google-api-php-client/contrib/google_predictionservice.php';              session_start();              $client = new google_client();              define("client_id", 'xxxxxxxxxxxxxx.apps.googleusercontent.com');             define("service_account_name", 'prediction api project');             define("key_file", 'google-api-php-client/xxxxxxxxcd-privatekey.p12');              $client = new google_client();             $key = file_get_contents(key_file);               $client->setassertioncredentials(new google_assertioncredentials(                                         service_account_name,                                         array('https://www.googleapis.com/auth/devstorage.full_control'),                                         $key));              $client->setclientid(client_id);              $predictionservice = new google_predictionservice($client);             $trainedmodels = $predictionservice->trainedmodels;                   $id = "languageidentifier";                 $predictiontext = "je suis vraiment très très fatigué";                 $predictiondata = new google_inputinput();                $predictiondata->setcsvinstance(array($predictiontext));                 $input = new google_input();                  $input->setinput($predictiondata);                 try{                 $result = $predictionservice->trainedmodels->predict($id, $input);                 print("<h2>prediction result:</h2>");                 print_r($result);                 }                  catch (exception $e)                 {                     echo '<pre>';                     print_r($e);                     echo '</pre>';                 }             ?> 

looks missing prediction in scopes

$client->setassertioncredentials(new google_assertioncredentials(                         email_address,                         array('https://www.googleapis.com/auth/devstorage.full_control','https://www.googleapis.com/auth/prediction'),                         $key)); 

it s ok now


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -