Cloud Datastore - Ошибка: 14 НЕДОСТУПНО: Ошибка получения метаданных из плагина. - PullRequest
0 голосов
/ 27 сентября 2018

Я получаю следующую ошибку при сохранении данных в облачном хранилище данных через nodejs sdk

 Error: 14 UNAVAILABLE: Getting metadata from plugin failed with error: Could not refresh access token.
 at Object.exports.createStatusError
     (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/common.js:87:15)
 at Object.onReceiveStatus
     (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:1188:28)
 at InterceptingListener._callNext
     (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:564:42)
 at InterceptingListener.onReceiveStatus
     (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:614:8)
 at callback
     (/user_code/node_modules/@google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:841:24)
 code: 14, metadata: Metadata { _internal_repr: {} },
     details: 'Getting metadata from plugin failed with error: Could not refresh access token.' 

И вот код:

// Imports the Google Cloud client library
const Datastore = require('@google-cloud/datastore');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Creates a client
const datastore = new Datastore({
  projectId: projectId,
});

// The kind for the new entity
const kind = 'Task';
// The name/ID for the new entity
const name = 'sampletask1';
// The Cloud Datastore key for the new entity
const taskKey = datastore.key([kind, name]);

// Prepares the new entity
const task = {
  key: taskKey,
  data: {
    description: 'Buy milk',
  },
};

// Saves the entity
datastore
  .save(task)
  .then(() => {
    console.log(`Saved ${task.key.name}: ${task.data.description}`);
  })
  .catch(err => {
    console.error('ERROR:', err);
  });

Следующая версия

"@google-cloud/datastore": "1.4.1",

1 Ответ

0 голосов
/ 08 октября 2018

Это происходит с конкретными проектами GCO, которые являются старыми, и API облачных функций никогда не сбрасывался после перехода на GA.

В соответствии с документацией [1] для взаимодействия облачных функций с хранилищем данных требуется следующая роль.

Учетная запись службы Cloud Functions (service-PROJECT_NUMBER@gcf-admin-robot.iam.gserviceaccount.com) имеет роль cloudfunctions.serviceAgent в вашем проекте.

и

Вы можете сбросить эту учетную запись службы на роль по умолчанию, повторно включив API облачных функций:

gcloud services enable cloudfunctions.googleapis.com

[1] https://cloud.google.com/functions/docs/concepts/iam#troubleshooting_permission_errors

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...