Node.js 无法从oauth2 office365日历API获取令牌

Node.js 无法从oauth2 office365日历API获取令牌,node.js,oauth-2.0,calendar,access-token,office365api,Node.js,Oauth 2.0,Calendar,Access Token,Office365api,我无法从office365 calendar API中获取令牌,在过去7到8个月内,它一直在工作,但突然出现了错误“需要一个数组或一个iterable对象,但得到了[object Null]” 你们可以在这里看到我的代码 var oauth2 = require("simple-oauth2")(ConfigOutlookCredentials); var scopes = ["openid","offline_access","profile", //here 'profile'

我无法从office365 calendar API中获取令牌,在过去7到8个月内,它一直在工作,但突然出现了错误“需要一个数组或一个iterable对象,但得到了[object Null]”

你们可以在这里看到我的代码

 var oauth2 = require("simple-oauth2")(ConfigOutlookCredentials);
 var scopes = ["openid","offline_access","profile",     //here 'profile' is added bz not able to getting EmailId in this function getEmailFromIdToken.
   "https://outlook.office.com/mail.read",
   "https://outlook.office.com/calendars.readwrite"
 ];

function getTokenFromCode(auth_code,callback) {
   logger.MessageQueueLog.log("info","auth_code: "+auth_code+" || redirectUri: "+redirectUri+" || scopes: "+scopes);
   oauth2.authCode.getToken({
      code: auth_code,
      redirect_uri: redirectUri,
      scope: scopes.join(" ")
   }, function(error, result) {
    logger.MessageQueueLog.log("info","error: "+util.format('%j',error.message)+" || result: "+util.format('%j',result));
    if (error) { 
        return callback(error,null);
    } else {
         var token = oauth2.accessToken.create(result); 
         return callback(null,token);
    }
  });
}
在重定向到我的Redirect Url并将相同的代码传递到上述函数“getTokenFromCode”后,我得到了代码,但仍然得到了错误,即“需要一个数组或iterable对象,但得到了[object Null]

请帮我解决这个问题。
提前谢谢。

我也犯了同样的错误。您正在使用来自的simple-oauth2-promise

我的解决方案是使用如下代码移动到:

var oauth2 = require('simple-oauth2').create({
            client: {
                id: service_data.clientID,
                secret: service_data.clientSecret
            },
            auth: {
                tokenHost: service_data.site,
                tokenPath: service_data.tokenPath
            }
        }

    );

    var tokenConfig = {
        code: data.code,
        redirect_uri: data.redirect_uri
    };

    return oauth2.authorizationCode.getToken(tokenConfig);
这是一个承诺。 希望有帮助