最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - OneDrive FilePicker "The provided value for the input parameter 'redirect_uri' is not vali

programmeradmin3浏览0评论

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 .htm#opening-files-on-onedrive

However I am continually getting the error

.srf?lc=1033#error=invalid_request&error_description=The+provided+value+for+the+input+parameter+'redirect_uri'+is+not+valid.+The+expected+value+is+'.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=".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'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./sdk/javascript-picker-saver.htm#opening-files-on-onedrive

However I am continually getting the error

https://login.live./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./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/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., www.mydomain., and www.mydomain./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.

Share Improve this question edited Apr 30, 2015 at 18:19 Geoff Whitfield asked Apr 30, 2015 at 16:39 Geoff WhitfieldGeoff Whitfield 431 silver badge6 bronze badges 9
  • Have you followed the instructions under "Setting up"? "Register your app to get an app ID (client ID), if you haven't already done so. Ensure that the web page that is going to reference the SDK is a Redirect URL under Application Settings." – user4570983 Commented Apr 30, 2015 at 17:15
  • I've updated the question, hopefully the updates provide an answer. I would have added a screenshot of the registration page but new users can't attach pictures. – Geoff Whitfield Commented Apr 30, 2015 at 19:50
  • In your app registration page, what do you have set for 'Mobile or desktop client app - yes or no' and 'Redirect URLs'? For a web app, the first one should be 'No' and you should have the exact redirect url you're using in the list. – daspek Commented Apr 30, 2015 at 23:59
  • daspek-thank you for the reply. "Mobile or desktop client app" is set to No- it is a web app. Target domain is blank, "restrict JWT issuing" is No, "redirect urls" is set to myname..au/redirect.html - which is a page on the domain. Still no joy. – Geoff Whitfield Commented May 2, 2015 at 3:19
  • Geoff, try setting 'restrict JWT issuing' to Yes, and also make sure you're redirecting to the same url scheme as was registered (http vs https). – daspek Commented May 3, 2015 at 18:05
 |  Show 4 more ments

5 Answers 5

Reset to default 2

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

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

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./en-us/documentation/articles/app-service-mobile-how-to-configure-microsoft-authentication/

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

I was following these instructions here

https://learn.microsoft./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...

@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./sdk/javascript-picker-saver.htm I am using the most recent version of Chrome.

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论