Google Actions - Access to Calendar API with access token fails

邮差的信 提交于 2019-12-01 23:02:48

I think the issue is that the structure of what you're using as the auth parameter isn't correct. You're passing it a string token, while it should be an OAuth2 object. See https://github.com/google/google-api-nodejs-client#making-authenticated-requests for details, but in short you will need to:

  1. Create an OAuth2 object

var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(
  YOUR_CLIENT_ID,
  YOUR_CLIENT_SECRET,
  YOUR_REDIRECT_URL
);
  1. Set the credentials (the access token).

oauth2Client.setCredentials({
  access_token: 'ACCESS TOKEN HERE'
});
  1. Use this oauth2Client object in the auth parameter in your event data / call.

var eventData = {
    auth: oauth2Client,
    ...
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!