NodeJS

2016-10-23 3 views
0

용 Google Cloud Prediction API 라이브러리의 서비스 계정 자격증 명을 인증하지 못했습니다. googleapis 라이브러리를 사용 중이었고 JWT를 사용하여 서비스 계정 자격 증명을 성공적으로 인증했습니다. 그런 다음 예언 API에 특정 모듈이 있지만 동일한 서비스 계정 자격 증명을 인증하지 못한 google-cloud 라이브러리를 발견했습니다.NodeJS

나는 구글 컴퓨팅 엔진 또는 앱 엔진을 사용하고 지역 developement에에서 작업

내가 문서에 코드를 따르지 않는 :

var key = require('./MY_SERVICE_ACCOUNT_CREDENTIALS.json') 
var prediction = require('@google-cloud/prediction')({ 
    projectId: 'MY_PROJECT_ID', 
    credentials: key 
}) 

prediction.getModels((err, models) => { 
    if (err) { 
    console.log(err) 
    return 
    } 

    console.log('Models:', models) 
}) 

그것은 반환

{ ApiError: Access to project denied: user requires read permissions.            
    at [here goes stack trace]                     
    code: 401,                          
    errors:                           
    [ { domain: 'global',                       
     reason: 'authError',                       
     message: 'Access to project denied: user requires read permissions.',          
     locationType: 'header',                      
     location: 'Authorization' } ],                    
    response: undefined,                        
    message: 'Access to project denied: user requires read permissions.' } 

I 돈을 어디서 잘못되는지 알 수 없으며 googleapis으로 인증하고 google-cloud 등과 통합해야하는지 잘 모르겠습니다. 또한 la 샘플의 CK

답변

0

그래서 나는 이것이 두 달 전이지만 오류 자체는 설명이 잘되어 있지만 나 자신도이 문제에 부딪쳤다.

기본적으로 서비스 키에는 프로젝트에서 정보를 읽거나 쓸 수있는 적절한 권한이 없습니다. 구글 클라우드 콘솔에서 IAM & 관리자에서 서비스 계정에 대한보고가 만든 서비스 계정에 프로젝트 → 편집기 및/또는 프로젝트 → 뷰어를 추가합니다. 이러한 권한을 추가하면 "저장"을 누르고 권한이 반영 되려면 약 20 초 정도 기다려야합니다.