Hi,
Step 1: Register an App in Azure AD
Go to https://portal.azure.com
Navigate to Azure Active Directory → App registrations
Click New registration
Name: TeamsWorkLocationUpdater
Supported account types: Select your org only (Single tenant)
Redirect URI: Leave blank (for now)
Click Register
Step 2: Add API Permissions
After registration, go to API Permissions
Click + Add a permission → Microsoft Graph
Choose Delegated permissions
User.ReadWrite
Presence.ReadWrite.All (if setting presence too)
User.ReadWrite.All
(Optional if setting working hours/locations via beta: UserSettings.ReadWrite)
Click Grant admin consent for your tenant.
Step 3: Create a Secret
Go to Certificates & secrets → New client secret
Description: PowerAutomateSecret
Expiry: 6-12 months recommended
Copy the secret value immediately. You’ll use it in Power Automate.
Step 4: Save App Details
Copy these and store them:
Tenant ID
Client ID
Client Secret (just generated)
PART 2: Build Power Automate Flow
Step 1: Your Existing Flow (as described)
You already have:
Recurrence trigger → Weekday check → List rows in Excel
Apply to each: For each user, send Teams Adaptive Card
Capture their response
Update row and append to master log
Step 2: Add Work Location Logic
➤ After capturing user’s response, insert a Switch or Condition
Condition:
If Response = "At Office" OR "Work - Other"
→ Set location variable = "Office"
Else
→ Set location variable = "Remote"
Step 3: Add HTTP Action to Call Graph API
➤ Add an HTTP step (Standard or Premium license required)
Use the values from Azure registration earlier.
Action: HTTP
Property Value
Method PATCH
URI https://graph.microsoft.com/beta/users/<UserEmail>/settings/workingLocation
Headers
{
"Authorization": "Bearer <access_token>",
"Content-Type": "application/json"
}
| Body (example): |
{
"location": {
"displayName": "@{variables('WorkLocation')}",
"building": "HQ",
"floor": "2",
"desk": "Unassigned"
},
"recurrence": {
"pattern": {
"type": "daily",
"interval": 1
},
"range": {
"type": "endDate",
"startDate": "@{utcNow('yyyy-MM-dd')}",
"endDate": "@{utcNow('yyyy-MM-dd')}"
}
}
}
Replace <UserEmail> with dynamic user email from your Excel sheet.
Step 4: Get Access Token via HTTP (Token Step)
Before the HTTP PATCH request above, insert a "Get Token" step.
➤ Add another HTTP action: Get Token
Property Value
Method POST
URI https://login.microsoftonline.com/<TenantID>/oauth2/v2.0/token
Headers
{
"Content-Type": "application/x-www-form-urlencoded"
}
| Body |
client_id=<YourClientID>
&scope=https://graph.microsoft.com/.default
&client_secret=<YourClientSecret>
&grant_type=client_credentials
➤ Parse Token:
Use a Parse JSON step to extract the access_token
Schema example:
{
"type": "object",
"properties": {
"access_token": {
"type": "string"
}
}
}
Use @body('Parse_Token')?['access_token'] in the Authorization header of your main HTTP request.
If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
Regards,
Riyaz