Set up Microsoft sign-in for connectors

Last published : Nov 23, 2026
This guide shows you how to let users sign in to connectors that Microsoft Entra ID protects, such as Microsoft Work IQ. Knowledge Worker Agent signs users in to these connectors itself, with an app that your organization registers in Microsoft Entra ID. One app serves every such connector.

Before you start

You need:
  • A role in Microsoft Entra ID that can register apps and grant admin consent, such as Cloud Application Administrator or Application Administrator.
  • The connector's address, and the permission it asks for. For Microsoft Work IQ, the address is https://workiq.svc.cloud.microsoft/mcp, and the permission is WorkIQAgent.Ask on the API with App ID fdcc1f02-fc51-4226-8753-f668596af7f7.
  • For Microsoft Work IQ, a Microsoft 365 Copilot license for each user.

Register the app

In the Microsoft Entra admin center:
  1. Go to App registrations, and select New registration.
  2. Enter a name, such as Knowledge Worker Agent.
  3. Under Supported account types, select Accounts in this organizational directory only.
  4. Under Redirect URI, select Public client/native (mobile & desktop), and enter http://localhost, with no port and no path.
  5. Select Register.
  6. Under Authentication, leave Allow public client flows set to No. Don't add a client secret or a certificate: Knowledge Worker Agent signs in with the authorization code flow and PKCE, as a public client.
Note the Application (client) ID and the Directory (tenant) ID on the app's Overview page.

Give the app its permissions

  1. In the app, go to API permissions, and select Add a permission.
  2. Under APIs my organization uses, find the connector's API, and add its permission as a Delegated permission. For Microsoft Work IQ, search for fdcc1f02-fc51-4226-8753-f668596af7f7, and add WorkIQAgent.Ask.
    If the API isn't listed, its service principal doesn't exist in your tenant yet. Create it, for example with Microsoft Graph PowerShell:
    Connect-MgGraph -Scopes "Application.ReadWrite.All"
    New-MgServicePrincipal -AppId fdcc1f02-fc51-4226-8753-f668596af7f7
  3. Add the Microsoft Graph delegated permission offline_access. Without it, users have to sign in again every hour.
  4. Select Grant admin consent for your organization.
To let only some users sign in, open the app under Enterprise applications, set Assignment required to Yes, and assign those users or a group.

Tell Knowledge Worker Agent about the app

Set these environment variables where Knowledge Worker Agent starts, for example in the workspace image:
Variable Value
KWA_ENTRA_CLIENT_ID The app's Application (client) ID.
KWA_ENTRA_TENANT_ID The Directory (tenant) ID, or a domain of your tenant.
Knowledge Worker Agent reads them the next time it starts.
With central configuration, a connector artifact can name its own app instead, with clientId and tenant in its kwa.auth block. Each overrides its environment variable. For example, an artifact for Microsoft Work IQ:
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "workiq": {
      "type": "remote",
      "url": "https://workiq.svc.cloud.microsoft/mcp"
    }
  },
  "kwa": {
    "description": "Ask about your mail, meetings, documents, and Teams messages.",
    "auth": {
      "type": "entra",
      "label": "Microsoft Work IQ",
      "clientId": "<Application (client) ID>",
      "tenant": "<Directory (tenant) ID>"
    }
  }
}
For how to assign it, see Set up central configuration. Without central configuration, users add the connector themselves, with its address.

What users see

When a user selects Sign in on the connector, they sign in with their Microsoft work account, then paste the address their browser lands on, as for other connectors. The connector's row then shows the account it's signed in as. For the steps, see Manage connectors.
Knowledge Worker Agent recognizes these connectors by the sign-in service they name, and uses its own sign-in for them only. Other connectors sign in as before.

How the sign-in is kept

  • The refresh token stays in the user's workspace, in .system/entra in the Knowledge Worker Agent folder, readable only by the user. opencode, which runs the connectors, gets only the access token.
  • Knowledge Worker Agent renews the access token about 10 minutes before it expires. While the assistant is working in a chat, it waits for it to finish, until 2 minutes before the token expires.
  • The token is sent only to the connector's address.
  • Signing out in Knowledge Worker Agent removes the tokens. To end access from Microsoft's side, revoke the user's sessions in Microsoft Entra ID.
Knowledge Worker Agent renews tokens from the user's workspace, not from the user's computer. A Conditional Access policy for the app that requires a compliant device or a named location can block the renewal. The connector then shows that the user needs to sign in again.

Troubleshoot

What users see What to do
"…signs in with Microsoft, which needs an app registered for Knowledge Worker Agent" Set KWA_ENTRA_CLIENT_ID and KWA_ENTRA_TENANT_ID, or clientId and tenant in the connector's artifact.
"…signs in with Microsoft, which needs opencode 2.x" The workspace runs opencode 1.x, with KWA_OPENCODE_MAJOR=1. Microsoft sign-in needs 2.x.
"An administrator has to approve this app for your organization first." (AADSTS65001) Grant admin consent for the app's permissions.
"Your account isn't assigned to this app in Microsoft Entra ID…" (AADSTS50105) Assign the user, or a group they're in, to the app.
"A sign-in policy of your organization blocked this sign-in." (AADSTS53003) Check which Conditional Access policy applies to the app.
"Microsoft can't find the app in your organization…" (AADSTS700016) Check the client ID and the tenant ID.
"Microsoft refused the return address…" (AADSTS50011) Register http://localhost as a redirect URI under Mobile and desktop applications.
"The app registration must allow public clients without a secret…" (AADSTS7000218) The redirect URI is registered under Web. Register it under Mobile and desktop applications instead.
"Your Microsoft sign-in has expired. Sign in again." (AADSTS70043, AADSTS700082) The refresh token expired or was revoked. The user signs in again.