Geoff Whitfield
Geoff Whitfield

Reputation: 43

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.

Upvotes: 3

Views: 5085

Answers (5)

James
James

Reputation: 53

I was following these instructions here

https://learn.microsoft.com/en-gb/onedrive/developer/controls/file-pickers/js-v72/open-file

I tried a few different things but what worked for me was just making the redirect_url the same as the url the file picker was opened from. So if I open the picker from the home page, the redirect url is also the home page. Seems to work on both localhost and an azure web app on the free plan. Here's a example of the urls i used...

enter image description here

Upvotes: 1

Ricardo Mancilla
Ricardo Mancilla

Reputation: 31

I have solved it, when you configure the Redirect URIs on https://apps.dev.microsoft.com/ you must put "/signin-microsoft" at the end.

Example: http://localhost:9000/signin-microsoft

Upvotes: 2

robinuk
robinuk

Reputation: 11

I had a similar problem, using the AzureSDK in Xamarin and what solved my issue was in the redirect url, in the Microsoft Developer Account pages, I had specified "http". I changed it to "https" and it worked great.

https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-how-to-configure-microsoft-authentication/

https://account.live.com/developers/applications/index

Upvotes: 1

Michal Macejko
Michal Macejko

Reputation: 370

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

Upvotes: 0

minnur
minnur

Reputation: 3290

@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.

Upvotes: 0

Related Questions