2017-07-28 20 views
5

私はoffice365カレンダーAPIからトークンを取得できませんでした。過去7〜8ヶ月間は機能していましたが、突然、「配列や反復可能オブジェクトを予期していますが、 [オブジェクトNull] "。oauth2からトークンを取得できませんoffice365カレンダーAPI

君たちはまだ私が期待してエラーすなわち「を得るM、ここに私のコード

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 URLと「getTokenFromCode」上記の関数に渡すのと同じコードにリダイレクトした後、コードを取得していますを見ることができます配列または反復可能オブジェクトですが、[object Null] "が見つかりました。

問題を理解するのを助けてください。 ありがとうございました。

答えて

0

私は同じエラーがありました。あなたは私のためにhttps://github.com/jonathansamines/simple-oauth2

ソリューションは、このようなコードでhttps://github.com/lelylan/simple-oauth2に動いていたから、簡単な-のOAuth2-約束を使用している:

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

を、これは約束を返します。 助けてください!

関連する問題