Advertisement
AkshayCS

Microsoft Teams - Force Online Availability to you Manager

Sep 28th, 2022
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 2.89 KB | Source Code | 0 0
  1. /*
  2. MS Teams - Force Online and Available Presence on your account.
  3.  
  4. 1. Copy the below code (then Ctrl + C) and paste in a notepad instance/file, or another text editor of your choice.
  5. 2. Visit https://teams.microsoft.com and sign in to your account (if required). If you are signed in, you should see your chats. Wait a minute or two for the teams to make its usual requests.
  6. 3. Open the developer tools option on your browser: Usually, you can press the F12 key on your keyboard when the teams tab is active and switch to the "Network" tab. Make sure you stay on the "Network" tab for the next steps.
  7. 4. Click on your profile icon on the top right.
  8. 5. 5. (Optional) Press the 'clear' button next to the round red button in the browser's dev console. This will clear the clutter so you will have fewer requests to search through, in the next steps.
  9. 6. Set your presence to "Busy" or "Do not disturb" or anything else of your choice.
  10. 7. Now in the developer console we opened in Step #3, look for an entry with the name "forceavailability/"
  11. 8. On this entry, look at the "Request Headers" and in "authorization:" header, copy the entire value, starting from the "Bearer eyJ0eXAiOiJK......" value till the end. This will differ for you. Paste this entire text value in the Bearer <token> area in the below code (in the copy you made in your notepad/text editor). Keep the "quotes" as-is. Now copy this entire modified code into your clipboard (Ctrl + A, then Ctrl + C)
  12. 9. Once you have updated the value in the code, switch back to the "Console" tab in your developer tools window. In the Console, click the last line that starts with > and now paste the updated code and press ENTER.
  13. 10. You should see a "<. undefined" response below.
  14.  
  15. Congratulations, now you will remain as "Available" in MS Teams for the rest of the day - or as long as you keep the browser tab unclosed. Use responsibly.
  16. If you are seeing a 401 message in red, it is because the Authorization token passed in the request is invalid. Please try again carefully, from the first step.
  17.  
  18. Credits: https://twitter.com/i/user/971266128608727040
  19. */
  20.  
  21. //Code begins below:
  22.  
  23. var data = JSON.stringify({
  24.   "availability": "Available",
  25.   "desiredExpirationTime": "2035-01-01T12:34:56.789Z"
  26. });
  27.  
  28. var xhr = new XMLHttpRequest();
  29. xhr.withCredentials = true;
  30.  
  31. xhr.addEventListener("readystatechange", function() {
  32.   if(this.readyState === 4) {
  33.     console.log(this.responseText);
  34.   }
  35. });
  36.  
  37. xhr.open("PUT", "https://presence.teams.microsoft.com/v1/me/forceavailability/");
  38. xhr.setRequestHeader("authority", "presence.teams.microsoft.com");
  39. xhr.setRequestHeader("accept", "json");
  40. xhr.setRequestHeader("accept-language", "en");
  41. xhr.setRequestHeader("authorization", "Bearer <token>"); //replace this line's data with your actual token.
  42. xhr.setRequestHeader("behavioroverride", "redirectAs404");
  43. xhr.setRequestHeader("content-type", "application/json");
  44.  
  45. xhr.send(data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement