onedrive.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <script src="//js.live.net/v5.0/wl.js"></script>
  6. </head>
  7. <body>
  8. <script>
  9. // Extract authentication info from redirect URL in popup window
  10. function getAuthInfoFromUrl()
  11. {
  12. if (window.location.hash != null)
  13. {
  14. try
  15. {
  16. var result = new Object();
  17. var authResponse = window.location.hash.substring(1);
  18. var params = authResponse.split('&');
  19. for (var i = 0; i < params.length; i++)
  20. {
  21. idx = params[i].indexOf('=');
  22. if (idx > 0)
  23. {
  24. result[params[i].substring(0, idx)] = params[i].substring(idx + 1);
  25. }
  26. }
  27. return result;
  28. }
  29. catch (e)
  30. {
  31. // ignores parsing errors
  32. }
  33. }
  34. return null;
  35. };
  36. // Main
  37. if (window.opener != null && window.opener.onOneDriveCallback != null)
  38. {
  39. try
  40. {
  41. var authInfo = getAuthInfoFromUrl();
  42. var token = authInfo['access_token'];
  43. window.opener.onOneDriveCallback(token, window);
  44. }
  45. catch (e)
  46. {
  47. alert('OneDrive: ' + e.toString());
  48. window.close();
  49. }
  50. }
  51. </script>
  52. </body>
  53. </html>