I'm using Skydrive file picker javascript api to upload files to Skydrive. But as soon as I click on upload button...it opens the login window and closes instantly. Error log shows that WL.login : The pop up is closed without receiving any consent.
I've hosted my web-app on local domain: apidomain and published my files to IIS @ Default Web Site/onedriveapi folder.
Following is the code:
[HTML]
<button onclick="uploadFile()">Save file</button>
<label id="info"></label>
[Javascript]
<script src="//js.live.net/v5.0/wl.js" type="text/javascript"></script>
<script type="text/javascript">
WL.init({
client_id: "00000000XXXXXXXX",
redirect_uri: "http://apidomain.com/onedriveapi/default.html",
scope: ["wl.signin", "wl.skydrive", "wl.skydrive_update"],
response_type: "token"
});
function uploadFile() {
WL.login({
scope: "wl.skydrive_update"
}).then(
function (response) {
alert(response);
WL.upload({
//path: "folder.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!170",
path: "response.data.folders[0].id",
element: "file",
overwrite: "rename"
}).then(
function (response) {
document.getElementById("info").innerText =
"File uploaded.";
},
function (responseFailed) {
document.getElementById("info").innerText =
"Error uploading file: " + responseFailed.error.message;
}
);
},
function (responseFailed) {
document.getElementById("info").innerText =
"Error signing in: " + responseFailed.error.message;
}
);
}
</script>
Redirect_URL in app settings is also same as mentioned above. I've also created callback.html as mentioned in few places, and replaced my redirect_url with
redirect_uri: "http://apidomain.com/onedriveapi/callback.html",
in page as well as appsettings of https://account.live.com/developers/applications/apisettings.
I also want to save the token received and location of the file uploaded into my db.Please anybody help to fix this issue as I'm struggling with this from last few days.
Thanks