This guide is for Microsoft Entra admins whose organisation doesn’t let users approve third-party apps themselves.
Why you’d do this
Section titled “Why you’d do this”When someone connects their own mailbox, Microsoft asks for permission for timetoreply to read it. If users can’t give that permission, every mailbox creates a separate admin approval request.
A custom app consent policy lets the users you choose approve timetoreply themselves, during the normal connection process.
| Users in the policy can | Users in the policy can’t |
|---|---|
| Connect their own mailbox to timetoreply | Get admin rights |
| Approve timetoreply’s permissions for themselves | Approve any other third-party app |
| Give timetoreply access to every mailbox in your tenant |
Each mailbox owner still connects their own mailbox. This is more restrictive than giving tenant-wide admin consent.
Choose your permissions
Section titled “Choose your permissions”timetoreply’s Microsoft application (client) ID is:
ca7f3ddb-4052-4e29-a3e1-9bef37e1bf4fThe permissions depend on whether email body ingestion is turned on in timetoreply:
| Email body ingestion | Permissions | What timetoreply can read |
|---|---|---|
| Off (standard) | offline_access, User.Read, Mail.ReadBasic |
Email metadata only. Not email bodies, previews, attachments or extended properties. |
| On | offline_access, User.Read, Mail.Read |
Email bodies too, so body-based features work. |
If you use timetoreply’s calendar sync, also add Calendars.Read to either set.
timetoreply also asks for Mail.Read when the first connection can’t subscribe to new mail, even if email body ingestion is off. Add Mail.Read to the off sets below if that retry should not need an admin.
Before you start
Section titled “Before you start”You need:
- A Microsoft Entra ID P1 or P2 licence. Microsoft needs one to create custom roles.
- Microsoft Graph PowerShell installed.
- A Microsoft Entra admin account that can manage app consent policies and directory roles.
- Permission to assign users or groups to custom Microsoft Entra roles.
Set it up
Section titled “Set it up”1. Connect to Microsoft Graph
Section titled “1. Connect to Microsoft Graph”Open PowerShell and run:
Connect-MgGraph -Scopes "Policy.ReadWrite.PermissionGrant", "RoleManagement.ReadWrite.Directory", "Application.Read.All"2. Set the application IDs
Section titled “2. Set the application IDs”# Microsoft Graph resource application ID$msGraphAppId = "00000003-0000-0000-c000-000000000000"# timetoreply Microsoft application/client ID$timetoreplyClientAppId = "ca7f3ddb-4052-4e29-a3e1-9bef37e1bf4f"3. Choose the permissions
Section titled “3. Choose the permissions”Run only one of these, to match your permissions.
Email body ingestion off:
$scopeNames = @("offline_access", "User.Read", "Mail.ReadBasic")# Or, if the new-mail subscription retry should not need an admin:# $scopeNames = @("offline_access", "User.Read", "Mail.ReadBasic", "Mail.Read")Email body ingestion on:
$scopeNames = @("offline_access", "User.Read", "Mail.Read")Email body ingestion off, with calendar sync:
$scopeNames = @("offline_access", "User.Read", "Mail.ReadBasic", "Calendars.Read")# Or, if the new-mail subscription retry should not need an admin:# $scopeNames = @("offline_access", "User.Read", "Mail.ReadBasic", "Mail.Read", "Calendars.Read")Email body ingestion on, with calendar sync:
$scopeNames = @("offline_access", "User.Read", "Mail.Read", "Calendars.Read")4. Look up the permission IDs
Section titled “4. Look up the permission IDs”$msGraph = Get-MgServicePrincipal -Filter "appId eq '$msGraphAppId'"$scopeIds = $msGraph.Oauth2PermissionScopes | Where-Object { $scopeNames -contains $_.Value } | Select-Object -ExpandProperty IdTo check you have the right ones:
$msGraph.Oauth2PermissionScopes | Where-Object { $scopeNames -contains $_.Value } | Select-Object Value, Id5. Create the consent policy
Section titled “5. Create the consent policy”$policyId = "timetoreply-user-consent-policy"$policyName = "timetoreply user consent policy"$policyDescription = "Allows assigned users to grant consent for the timetoreply application for approved Microsoft Graph delegated permissions."
New-MgPolicyPermissionGrantPolicy ` -Id $policyId ` -DisplayName $policyName ` -Description $policyDescription6. Limit the policy to timetoreply
Section titled “6. Limit the policy to timetoreply”This rule allows only timetoreply, and only the permissions you chose:
New-MgPolicyPermissionGrantPolicyInclude ` -PermissionGrantPolicyId $policyId ` -PermissionType "delegated" ` -PermissionClassification "all" ` -ClientApplicationIds @($timetoreplyClientAppId) ` -Permissions $scopeIds ` -ResourceApplication $msGraph.AppId7. Create a custom role
Section titled “7. Create a custom role”This role lets users give consent for themselves only, through the policy:
$roleDisplayName = "timetoreply mailbox users"$roleDescription = "Allows assigned users to grant consent to timetoreply on behalf of themselves only."$templateId = (New-Guid).Guid$rolePermissions = @{ allowedResourceActions = @( "microsoft.directory/servicePrincipals/managePermissionGrantsForSelf.$policyId" )}
New-MgRoleManagementDirectoryRoleDefinition ` -DisplayName $roleDisplayName ` -Description $roleDescription ` -TemplateId $templateId ` -IsEnabled:$true ` -RolePermissions $rolePermissions8. Assign users or groups to the role
Section titled “8. Assign users or groups to the role”- In the Microsoft Entra admin center, go to Roles & admins.
- Search for and open the timetoreply mailbox users role.
- Click Add assignments.
- Add the users or groups who should be able to connect their own mailbox.
9. Ask users to connect their mailbox
Section titled “9. Ask users to connect their mailbox”Once the role assignments have taken effect, users can connect their mailbox. They may still see Microsoft’s permission screen, but they can approve it themselves without creating an admin approval request.
Check the setup
Section titled “Check the setup”List your app consent policies:
Get-MgPolicyPermissionGrantPolicy | Format-Table Id, DisplayName, DescriptionSee the rules in the timetoreply policy:
Get-MgPolicyPermissionGrantPolicyInclude ` -PermissionGrantPolicyId "timetoreply-user-consent-policy" | Format-ListRemove the setup
Section titled “Remove the setup”-
Remove all users and groups from the timetoreply mailbox users role.
-
Delete the consent policy:
Terminal window Remove-MgPolicyPermissionGrantPolicy `-PermissionGrantPolicyId "timetoreply-user-consent-policy" -
Delete the custom role from Roles & admins in the Microsoft Entra admin center.