Give Presence.Read.All permission for continuous-running scripts

SATO Yusuke 21 Reputation points
2021-11-29T16:47:47.837+00:00

Background

  • I am writing a script that records our staff's presence in Office365 to assist attendance management.
  • The script uses Microsoft Graph REST API (GET /users/{id}/presence) to get one's presence.
  • The script runs from Task Scheduler periodically with the Run whether user is logged on or not option.
  • The script runs continuously, so I think I have to register this script to Azure Active Directory so that the script can update the access token to call Microsoft Graph REST API. ## Problem

To test This script, I am using Microsoft 365 developer instant sandbox. When I register the script to Azure Active Directory and request API permissions, I have selected "Application permissions" because the script runs in the background. But with this selection, I could not select the "Presence.Read.All" permission.
153434-applicationpermissions.png

The permission "Presence.Read.All" is permission is required from the "GET /users/{id}/presence" API endpoint.
153357-presence.png

You can select the Presence.ReadWrite.All permission, but I cannot use this permission because it requires Admin consent (I am not an administrator of Azure AD of our company). Also, I don't want to use this permission to avoid additional security risks. The script reads one's presence but doesn't modify it, so the Presence.Read.All permission is enough for the script.

You can select the Presence.Read.All permission when you select Delegated permissions, but I think this option is not suitable for the script because it runs even if I have logged out from Windows.
153390-delegatedpermissions.png

Question

How can I give minimum requisite permissions to a continuous-running script that uses GET /users/{id}/presence API endpoint?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,567 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. awijekoon 950 Reputation points Microsoft Vendor
    2024-01-14T22:30:33.8+00:00

    @SATO Yusuke Get User Presence API with Application Permission now available in Graph v1.0.
    for more details See this comment The Graph API change log and documentation is not yet updated. If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.

    0 comments No comments