我正在使用“ googleapis”节点模块。几天以来,我开始出现以下错误:


  this.oauth2Client.setCredentials不是函数..


代码:

var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
this.oauth2Client = new OAuth2(endpointdetails.gss_endpoint.targetBinding[0].value, endpointdetails.gss_endpoint.targetBinding[1].value);
this.oauth2Client.setCredentials({
    access_token: endpointdetails.gss_endpoint.targetBinding[2].value,
    refresh_token: endpointdetails.gss_endpoint.targetBinding[3].value,
    expiry_date: true
});

最佳答案

尝试使用:

oauth2Client.credentials = tokens;


代替

oauth2Client.setCredentials(tokens);


https://github.com/google/google-api-nodejs-client/issues/869#issuecomment-346533545

关于node.js - setCredentials不是googleapis.auth.OAuth2中的函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47550267/

10-11 08:17