I was using googleapis
library and successfully authenticate my Service Account credentials using JWT. Then I found out google-cloud
library, which has specific modules for Prediction API, but failed to authenticate the same Service Account credentials.
I don't use Google Computing Engine or App Engine and working in local developement
I follow code in documentation:
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)
})
and it returns:
{ 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 don't know where it goes wrong and I'm not sure if I would need to authenticate with googleapis
and integrate it with google-cloud
or etc. It's also lack of samples