One Drive API - 如何查找正确的重定向URI

时间:2018-05-24 15:23:05

标签: javascript onedrive

我是使用OneDrive API的初学者。我正在构建一个应用程序,用户可以在OneDrive中上传和查看文件。我在第一步,身份验证方面遇到了问题。

我已经在Microsoft的应用程序注册门户中注册了我的应用程序并使用OneDrive File Picker - Javascript SDK启动。

我的javascript代码如下所示:

$('#resultsTable').on('click', 'tr > td > .view-onedrive', function(){
 var odOptions = {  
         clientId: "05xxxxxxxxxxxxx-xxxxx-xxxxx",
         redirectUri: location.origin,
         action: "query",
         multiSelect: true,
         advanced: {},
         success: function(files) { 
          var promise1 = Promise.resolve(files);

          promise1.then(function(value) {
          console.log(value);
          }); 

        },
         cancel: function() { /* cancel handler */ },
         error: function(e) { 
          function rejected(e) {
          console.log(e);
          }

          Promise.reject(new Error('fail'))}
          };
          OneDrive.open(odOptions);
});

使用上面的javascript代码,这是显示在网址中的错误消息:

https://login.live.com/err.srf?lc=1033#error=invalid_request&error_description=The+provided+value+for+the+input+parameter+'redirect_uri'+is+not+valid.+The+expected+value+is+'https://login.live.com/oauth20_desktop.srf'+or+a+URL+which+matches+the+redirect+URI+registered+for+this+client+application.&state=http://mydevserver.com_m48KW

根据我收集的内容,错误是我的请求中的重定向URI与Developer's Portal中注册的重定向URI不匹配。虽然,它已在我的开发人员门户网站中注册,如下所示。

Developer's Portal Redirect URI

我用了#34; https://login.live.com/oauth20_desktop.srf"因为我不知道重定向uri在我的本地机器上会是什么。 Localhost不起作用。它不活,我在我的本地机器上开发网站。

我的整体问题是如何获得正确的重定向URI?

0 个答案:

没有答案