0

我目前正在嘗試使用從前端通過adaljs獲取的訪問令牌從php後端查詢Office365 API。來自前端的API調用非常完美。然而,使用同樣從後端和郵差API調用失敗,出現錯誤:2000000;reason="The token has an invalid signature.";error_category="invalid_signature"Office365 API:令牌具有無效簽名

前端(工作)例如:

$http.get("https://outlook.office365.com/api/v1.0/me/calendarview?StartDateTime=2016-08-02T00:00:00Z&EndDateTime=2016-08-02T23:59:00Z") //working 
      .then(function (response) { 
       $log.debug('HTTP request to Calendar API returned successfully.'); 
       console.log(response); 
      }, function (error) { 
       $log.error('HTTP request to Calendar API failed.'); 
       console.log(error); 
      }); 

獲取該Office365 API(不是我的客戶端應用程序令牌),並存儲在數據庫:

adalAuthenticationService.acquireToken('https://outlook.office365.com').then(function(refreshToken) { 

      var data = { 

       code: refreshToken, 
       email: email 

      }; 

      console.log(refreshToken); 

      Office365.createIntegration('office365', data) 

       .then(function() { 

        console.log("link created"); 
        $scope.loading = false; 


       }, function(error) { 

        console.error(error); 
        $scope.loading = false; 

       }) 

     }, function(err) { 

      console.error(err); 

     }); 

JWT一直aud: "https://outlook.office365.com",正確設置太

+1

錯誤表示簽名不正確。我建議你使用** Fiddler **來跟蹤你在**前端**中使用的訪問令牌。然後,您可以將它與使用PHP後端和Postman的令牌進行比較,以查看它是否不同。 –

+0

你是對的,謝謝! –

回答

1

我覺得真的很傻,但我的訪問令牌WASN不會在其他代碼中更新到數據庫中(它看起來像它,但它不是)。所以訪問令牌是無效的,因此是錯誤的。如果你看到這個,確保你的訪問令牌是有效的/最近的令牌!