microsoft_sdk.dtl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <script>
  2. WL.init({ client_id: "{{client}}", redirect_uri: "{{redirect}}" });
  3. //WL.Event.subscribe("auth.login", onLogin);
  4. //WL.Event.subscribe("auth.sessionChange", onSessionChange);
  5. function microsoft_login2() {
  6. var session = WL.getSession();
  7. if (session) {
  8. console.log("You are already signed in!");
  9. } else {
  10. WL.login({ scope: "wl.signin" });
  11. }
  12. }
  13. function microsoft_login() {
  14. WL.login({ "scope": "wl.basic" }).then(
  15. function (response) {
  16. showUserData();
  17. },
  18. function (response) {
  19. log("Could not connect, status = " + response.status);
  20. }
  21. );
  22. }
  23. function showUserData() {
  24. WL.api({ path: "/me", method: "GET" }).then(
  25. function (response) {
  26. winLogin(JSON.stringify(response));
  27. },
  28. function (response) {
  29. log("API call failed: " + JSON.stringify(response.error).replace(/,/g, "\n"));
  30. }
  31. );
  32. }
  33. function onLogin() {
  34. var session = WL.getSession();
  35. if (session) {
  36. console.log("You are signed in!");
  37. console.log("{{event}}");
  38. }
  39. }
  40. function onSessionChange() {
  41. var session = WL.getSession();
  42. if (session) {
  43. winLogin(session);
  44. console.log("Your session has changed.");
  45. console.log(session);
  46. }
  47. }
  48. </script>