Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Some agents in a fleet need a user object for Microsoft 365 workloads, such as a mailbox or Teams membership. For those agents, look up both the agent identity and its agent's user account in the agent directory, and pass them in the AgentIdentity and AgentUserId parameters.
To decide whether an agent needs an agent's user account, see Use an agent's user account with Microsoft 365.
Prerequisites
- Complete Call APIs as an agent in a fleet with the Auth SDK sidecar.
- An agent's user account provisioned for the agent.
- Delegated permissions for the target API, such as
Mail.ReadWrite, granted to the agent identity or inherited from the blueprint. - The Microsoft 365 licenses and resource access that the agent's user account needs. For details, see Configure the account.
Configure the sidecar
Add a delegated Microsoft Graph profile to the runtime sidecar:
{
"DownstreamApis": {
"MsGraph": {
"BaseUrl": "https://graph.microsoft.com/v1.0/",
"Scopes": [
"Mail.ReadWrite"
]
}
}
}
Replace Mail.ReadWrite with the delegated permissions the agents need. The GetAuthorizationHeaderUnauthenticated override from the previous article also covers the AgentUserId parameter.
Get a token for an agent's user account
def authorization_header_for_agent_user(agent_id: str, api_name: str) -> str:
registration = directory.find(agent_id)
if registration is None or not registration["agent_user_id"]:
raise LookupError(f"Agent '{agent_id}' doesn't have an agent's user account.")
response = requests.get(
f"{SIDECAR_URL}/AuthorizationHeaderUnauthenticated/{api_name}",
params={
"AgentIdentity": registration["agent_identity_id"],
"AgentUserId": registration["agent_user_id"],
},
timeout=5,
)
response.raise_for_status()
return response.json()["authorizationHeader"]
graph_response = requests.get(
"https://graph.microsoft.com/v1.0/me/messages",
headers={"Authorization": authorization_header_for_agent_user(agent_id, "MsGraph")},
timeout=10,
)
graph_response.raise_for_status()
The token represents the agent's user account, so /me returns that account's data. Each agent can reach only the mailbox, files, and teams that its own account was given.
Next step
Authenticate users and route requests to agents in a fleet with the Auth SDK sidecar