How to use one drive file picker in browser?

杀马特。学长 韩版系。学妹 提交于 2019-12-08 04:46:25

问题


I need to integrate One Driver file picker in my website. I am using this js lib to do the task.

<script type="text/javascript" src="//js.live.net/v5.0/wl.js"></script>

The code I wrote is

WL.init({ client_id: "000000004C1xxxxx", redirect_uri: 'https://xxx.net/' });
WL.login({
        scope: "wl.skydrive wl.signin"
    }).then(
        function(response) {
            WL.fileDialog({
                mode: "open",
                select: "multi"
            }).then(
                function (response) {
                },
                function (responseFailed) {
                }
            );
        },

        function(response) {
            log("Failed to authenticate.");
        }
    );

It showed the popup window, and went through the authentication process. However once I've logged in within the popup window. It just redirected to the redirect URL I provided, the file picker never showed. Any ideas?


回答1:


I solved this issue by including the js script in my callback page, wl sdk will automatically handle the oauth process for you.

<script type="text/javascript" src="//js.live.net/v5.0/wl.js"></script>

It's weird as I could not find any documents related to how you should do with your callback page on MS developer website.




回答2:


Can you get the "Using the open from OneDrive picker" sample working on http://isdk.dev.live.com?




回答3:


Use the function below in your js file and don't forget to include :

<script type="text/javascript" src="https://js.live.net/v7.0/OneDrive.js"></script>




 function launchOneDrivePicker() {
        var odOptions = {
            clientId: "*******************************",
            action: "download",
            multiSelect: true,
            openInNewWindow: true,
            advanced: {
                queryParameters: "select=id,name,size,file,folder,photo",

                redirectUri: (Eneter your default url e.g :)"http://localhost:60666/WebForm1.aspx"
            },
            success: function (response) { /* success handler */      },
            cancel: function () { /* cancel handler */ },
            error: function (e) { /* error handler */ },
        };
        OneDrive.open(odOptions);
    }

I hope it works for everyone thanks.



来源:https://stackoverflow.com/questions/25357750/how-to-use-one-drive-file-picker-in-browser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!