microsoft / microsoft/Dataverse-skills
Interactive auth fails on macOS: "Interactive requests with mac broker enabled must be executed on the main thread"
- Dominant language
- No language data
- Stars
- 226
- Forks
- 61
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 7
Description
## Summary
`dataverse auth create` fails on macOS before any network request is made. The CLI enables the macOS MSAL broker but invokes `AcquireTokenInteractive` off the main thread, which MSAL rejects. This is independent of tenant configuration, network, and device state.
## Environment
- `@microsoft/dataverse` 1.0.59
- macOS, Apple Silicon
- .NET 10.0.103, Node 25.6.1
## Repro
```
dataverse auth create --environment https://.crm4.dynamics.com/
```
## Result
```
Microsoft.Identity.Client.MsalClientException: Interactive requests with mac broker enabled must be executed on the main thread on macOS.
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.ExecuteAsync(CancellationToken)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken)
at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters, AcquireTokenInteractiveParameters, CancellationToken)
at DataverseCli.Auth.AuthTokenStore.AcquireTokenForPublicClientFlow(String authorityUrl, String[] scopes, PublicClientAuthFlow authFlow, AuthClientConfig clientConfig)
at DataverseCli.Auth.AuthTokenStore.AcquireTokenAsync(String authorityUrl, String[] scopes, AuthenticationFlow authFlow, CloudInstance cloudInstance, AuthClientConfig clientConfig)
at DataverseCli.Auth.AuthTokenStore.CreateAuthProfileAsync(AuthName profileName, AuthenticationFlow authFlow, CloudInstance cloudInstance, Nullable`1 tenantId, Uri environmentUrlHint, AuthClientConfig clientConfig)
```
## Scope of the failure
- Reproduces identically under zsh and PowerShell 7.6, so it is not shell-dependent.
- `--deviceCode` reaches Entra normally and behaves as expected, so the defect is specific to the interactive path.
- The same command succeeds on Windows 11 with the same CLI version against the same environment, so it is macOS-specific.
- `dataverse auth` exposes no option to disable the broker or select an authentication flow, so there is no user-side workaround.
## Impact
On its own this is recoverable by using `--deviceCode`. However, device-code flow is blocked by Conditional Access in many enterprise tenants as a standard anti-phishing control. In such a tenant this leaves **no working authentication path on macOS at all** - interactive fails with the above, and device code is refused with `AADSTS53003`.
That combination is described in more detail in #108, which covers the related failure of `scripts/auth.py` to obtain a token. Filing this separately because the defect is in `DataverseCli.Auth.AuthTokenStore` rather than in the Python credential chain.
## Suggested fix
Marshal the interactive token request to the main thread on macOS, or expose a flag to disable the broker and fall back to the system browser.
Contributor guide
Assessment
This issue has not been assessed yet.