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

问题描述:

我无法从office365日历API获取令牌,从最近7到8个月它正在工作,但突然间我收到错误“期待数组或迭代对象,但得到了[对象为空]“。无法从oauth2获取令牌office365日历API

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

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); 
    } 
    }); 
} 

我重定向到我的rediredct地址和相同的代码传递给上面的函数“getTokenFromCode”后获得的代码,我仍m到处错误,即“期待的数组或可迭代的对象,但得到[对象为空]“。

请帮助我找出问题。 在此先感谢。

我有同样的错误。

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); 

这将返回一个承诺:我将移居https://github.com/lelylan/simple-oauth2有这样的代码,你正在使用从https://github.com/jonathansamines/simple-oauth2

解决简单的oauth2-承诺。 希望它有帮助!