onedrive3.html 1.2 KB

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