JavaEar 专注于收集分享传播有价值的技术资料

OneDrive FilePicker "The provided value for the input parameter 'redirect_uri' is not valid"

I've spent a lot of time searching and trying to find a solution, so far without success.

I'm trying to implement a simple OneDrive filepicker as per https://dev.onedrive.com/sdk/javascript-picker-saver.htm#opening-files-on-onedrive

However I am continually getting the error

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=redirect_type%3dauth%26display%3dpage%26request_ts%3d1430410948914%26response_method%3durl%26secure_cookie%3dfalse

I have tried different options originally with localhost, but even when I load up a page onto a simple domain I get the same message.

I have tried variations of the redirect url- none appear to work.

My web page:

<html>
<head>
    <title>OneDrive</title>
    <script type="text/javascript" src="https://js.live.net/v5.0/OneDrive.js" id="onedrive-js"
            client-id="00000000xxxxxxxx"></script>
    <script type="text/javascript">
        function ShowOnedrivePicker() {
            var oneDrivePickerOptions = {
                success: function (files) {
                    alert( files[0].link + "  name:" + files[0].name);
                },
                cancel: function () {
                    // handle when the user cancels picking a file
                },
                linkType: "webViewLink",
                multiSelect: false
            }
            OneDrive.open(oneDrivePickerOptions);
        }
    </script>
</head>
<body>
    <button onclick="ShowOnedrivePicker()">One Drive Picker</button>
</body>
</html>

I have registered and have a client ID, and have tried variations of the redirect URL in the API settings, such as mydomain.com, www.mydomain.com, and www.mydomain.com/redirect with no success.

While I have found many good solutions in Stack Overflow previously this is the first time I have asked a question. Thank you.

4个回答

    最佳答案
  1. 参考答案2
  2. 参考答案3
  3. @daspek I think it makes sense to let authenticate a user on a different callback URL. The main reason is that the OneDrive button could be simply used on the admin site of the site that's not accessible by anonymous users.

    I am currently implementing a new plugin for Drupal and content types are dynamically created and the URL paths look something like this:

    node/add/[type] where [type] could be article, page or any other name. So in order to be able to use the OneDrive picker plugin I have to add all those links to the App settings.

    Also the button doesn't work well on the second and Nth clicks. First click on the button triggers the popup but the following clicks won't.

    I was able to verify the issue today: https://dev.onedrive.com/sdk/javascript-picker-saver.htm I am using the most recent version of Chrome.

  4. 参考答案4
  5. I was struggling with the same problem and eventually I've found the solution.

    1. Development environment
      • you have to map your "fake" domain to the localhost
      • 127.0.0.1 www.my-project-localhost.sk (in hosts file)
      • in Microsoft Applications settings you have to provide your redirect url, in this case should be like http://www.my-project-localhost.sk
      • if you're running Rails project therefore your application is running on the port 3000, you should provide this port into redirect url as well, therefore your redirect url should be like http://www.my-project-localhost.sk:3000