Skip to content

Mismatch in MS Graph SDK with MS Graph REST API for RevokeSignInSessions endpoint #238

@lapellaniz

Description

@lapellaniz

Describe the bug
The MS Graph SDK has a mismatch on the response schema it expects vs what the MS Graph REST API returns for the "RevokeSignInSessions" endpoint.

The IUserRevokeSignInSessionsRequest.PostAsync returns a Task but the API response payload wraps that bool in a complex object and the SDK fails to deserialize.

The API states just a boolean should be returned - https://docs.microsoft.com/en-us/graph/api/user-revokesigninsessions?view=graph-rest-1.0&tabs=http

To Reproduce
Steps to reproduce the behavior:

  1. Create an AAD application with the Directory.ReadWrite.All application permission
  2. Create a .NET Core console application using the MS Graph SDK version 1.21.0
            IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                .Create("{enter client_id}")
                .WithClientSecret("{enter client_secret}")
                .Build();

            ClientCredentialProvider authenticationProvider = new ClientCredentialProvider(confidentialClientApplication);

            GraphServiceClient graphServiceClient = new GraphServiceClient(authenticationProvider);
            var result = await graphServiceClient
                .Users["{enter user_id}"]
                .RevokeSignInSessions()
                .Request()
                .PostAsync();

Actual Results

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Edm.Null",
    "@odata.null": true
}

Expected behavior
The successful request should correctly deserialize the response and not error out.

Screenshots
Error message differes b/w .NET Framework 4.8 and .NET Core. In .NET Core the error is:

Newtonsoft.Json.JsonReaderException
  HResult=0x80131500
  Message=Unexpected character encountered while parsing value: {. Path '', line 1, position 1.
  Source=Newtonsoft.Json
  StackTrace:
   at Newtonsoft.Json.JsonTextReader.ReadAsBoolean()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
   at Microsoft.Graph.Serializer.DeserializeObject[T](String inputString)
   at Microsoft.Graph.ResponseHandler.<HandleResponse>d__2`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.Graph.BaseRequest.<SendAsync>d__31`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at AzureAdGraphNetCoreSample.Program.<CallUsingCreateClientCredentialProvider>d__1.MoveNext() in C:\Users\lapellan\source\repos\AzureAdGraphSample\AzureAdGraphNetCoreSample\Program.cs:line 34
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at AzureAdGraphNetCoreSample.Program.Main(String[] args) in C:\Users\lapellan\source\repos\AzureAdGraphSample\AzureAdGraphNetCoreSample\Program.cs:line 17

Desktop (please complete the following information):

Additional context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions