microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

CAE error after version 5.56.1

Open
#3,056 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

Describe the bug

Previous to version 5.56.1 we were able to list the drives of a sharepoint site.
After the mentioned version the request fails with the following error message:

Microsoft.Graph.Models.ODataErrors.ODataError: 'Continuous access evaluation resulted in challenge with result: InteractionRequired and code: LocationConditionEvaluationSatisfied'

The request is done with an app registration with client id and client secret

var options = new ClientSecretCredentialOptions();
var clientSecretCredential = new ClientSecretCredential("tenant-id", "client-id", "secret", options);

var httpClient = GraphClientFactory.Create();
var client = new GraphServiceClient(httpClient, clientSecretCredential, scopes);

await client
    .Sites["site-id"]
    .Drives
    .GetAsync();

Getting the token on its own and then accessing the drives with the token works as expected.

var scopes = new[] { "https://graph.microsoft.com/.default" };
var clientSecretCredential = new ClientSecretCredential("tenant-id", "client-id", "secret");
var tokenRequestContext = new TokenRequestContext(scopes);

var token = await clientSecretCredential.GetTokenAsync(tokenRequestContext);

var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Token);

var response = await httpClient.GetAsync("https://graph.microsoft.com/v1.0/sites/site-id/drives");
var body = await response.Content.ReadAsStringAsync();
Expected behavior

Client should return the drives without error.

How to reproduce
var options = new ClientSecretCredentialOptions();
var clientSecretCredential = new ClientSecretCredential("tenant-id", "client-id", "secret", options);

var httpClient = GraphClientFactory.Create();
var client = new GraphServiceClient(httpClient, clientSecretCredential, scopes);

await client
    .Sites["site-id"]
    .Drives
    .GetAsync();
SDK Version

5.56.1

Latest version known to work for scenario above?

5.56.0

Known Workarounds

No response

Debug output
Configuration
  • OS: Windows 11 Enterprise
  • Architecture: x64
  • Happens also on MacOS
Other information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the 5.56.0 and 5.56.1 request paths around GraphClientFactory, ClientSecretCredential, and the Sites/{site-id}/Drives request. Reproduce the request with the supplied client-credentials example and compare it with the working manually acquired token; done means listing drives succeeds in the SDK without that workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, authentication
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.