В проекте мы использовали SpeechClient пакета google/cloud. Сейчас я обновляю его до не устаревшей версии /V1/SpeechClient, но у меня возникла проблема, связанная со следующей ошибкой
"Google\ApiCore\ApiException: {
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https:\/\/developers.google.com\/identity\/sign-in\/web\/devconsole-project.",
"code": 16,
"status": "UNAUTHENTICATED",
"details": []
}
Эта информация для аутентификации работает в предыдущей версии, и я пытался перейти на новые способы аутентификации, но, похоже, я делаю это неправильно. Любая помощь?
Предыдущая настройка:
// $auth is keyfile in an Array format. it matches the design given in here, with the edit fields filled
// https://cloud.google.com/iam/docs/keys- ... te-console
$auth = [
"type" => "service_account",
"project_id" => "",
"private_key_id" => "",
"private_key" => "-----BEGIN PRIVATE KEY-----\n\n-----END PRIVATE KEY-----",
"client_email" => "",
"client_id" => "",
"auth_uri" => "https://accounts.google.com/o/oauth2/auth",
"token_uri" => "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url" => "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url" => "https://www.googleapis.com/robot/v1/met ... ccount.com",
];
$speech = new Google\Cloud\Speech\SpeechClient([
'keyFile' => $auth,
]);
// Same auth used for storageClient
$storage = new Google\Cloud\Storage\StorageClient([
'keyFile' => $auth
]);
Обновление:
// $auth is the same as above
$creds = CredentialsWrapper::build([
'keyFile' => $auth
]);
// Create the speech client
$speech = new Google\Cloud\Speech\V1\SpeechClient([
'credentials' => $creds,
]);
// old auth still used for Storage
$storage = new Google\Cloud\Storage\StorageClient([
'keyFile' => $auth
]);
...
$operation = $speech->longRunningRecognize(
$config,
$audio
);
// gives me output as normal
$operation->getName();
// throws exception at the top of the post
$operation->reload();
Подробнее здесь: https://stackoverflow.com/questions/780 ... hclient-v1