Google의 클라우드 음성 API를 사용하여 애플리케이션을 만들려고합니다. 나는 모든 리포지토리를 복제하고 C++로 정말 간단한 클라이언트 응용 프로그램을 만들었습니다.grpc Google 로그인이 실패했습니다.
#include <grpc++/grpc++.h>
#include "google/cloud/speech/v1/cloud_speech.grpc.pb.h"
namespace gs=google::cloud::speech::v1;
using gs::Speech;
using gs::RecognizeResponse;
using gs::RecognizeRequest;
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
int main(int argc, char** argv) {
try{
auto channel_creds = grpc::GoogleDefaultCredentials();
auto channel = grpc::CreateChannel("speech.googleapis.com:443", channel_creds);
auto stub = Speech::NewStub(channel);
RecognizeResponse res;
RecognizeRequest req;
ClientContext ctx;
auto status = stub->Recognize(&ctx, req, &res);
if(status.ok())
{
std::cout << "ok" << std::endl;
} else {
std::cout << status.error_code() << ": " << status.error_message() << std::endl;
}
}catch(const std::exception& e)
{
std::cout<<e.what()<<std::endl;
}
std::cin.get();
}
이 잘 컴파일하지만 다음과 같은 오류 메시지가 발생 실행될 때 :
16 : 요청이 유효하지 않은 인증 자격 증명을 가지고 있었다. 예상 OAuth 2 액세스 토큰, 로그인 쿠키 또는 기타 유효한 인증 자격 증명입니다. https://developers.google.com/identity/sign-in/web/devconsole-project을 참조하십시오.
나는 서비스 계정을 생성하고는 ENV 변수 "GOOGLE_APPLICATION_CREDENTIALS"옆에 올바른 파일을 JSON 키 파일이고 (나는 그것을 제거하면, 그냥 충돌 때문에) 나는 그것을 읽어 꽤 확신 배치 . 나는 또한 연설 API를 온라인으로 가능하게했다. 내가 뭘하든 상관없이 나는 생각을 잃는다. 내가 빠진 것이 있습니까?