Closed
Description
Which version of Microsoft Identity Web are you using?
Note that to get help, you need to run the latest version.
Where is the issue?
- Web API
- Protected web APIs call downstream web APIs
Is this a new or an existing app?
This is a new app or an experiment.
Repro
[HttpGet]
public async Task<ActionResult> Register()
{
var result = await _graphServiceClient.Subscriptions.Request()
.GetAsync();
var notificationChannel = result.FirstOrDefault();
if (notificationChannel is null)
{
var r = await _graphServiceClient.Subscriptions.Request().AddAsync(new Microsoft.Graph.Subscription
{
ChangeType = "created",
NotificationUrl = "https://teamer.servicebus.windows.net/dave-apidesktop-ojevm42/api/webhook",
Resource = "/chats/getAllMessages",
ExpirationDateTime = new DateTimeOffset(DateTime.UtcNow.AddMinutes(30)),
ClientState = "TeamerNotifications",
});
}
else
{
}
return Ok();
Expected behavior
Subscription in the graph is created or an exception from the Graph API it self
Actual behavior
Exception in .net code
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
Status Code: 0
Microsoft.Graph.ServiceException: Code: generalException
Message: An error occurred sending the request.
---> System.FormatException: Cannot add value because header 'Authorization' does not support multiple values.
at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(HeaderDescriptor descriptor, HeaderStoreItemInfo info, String value)
at System.Net.Http.Headers.HttpHeaders.Add(String name, String value)
at Microsoft.Identity.Web.TokenAcquisitionCredentialProvider.AuthenticateRequestAsync(HttpRequestMessage request)
at Microsoft.Graph.AuthenticationHandler.SendRetryAsync(HttpResponseMessage httpResponseMessage, IAuthenticationProvider authProvider, CancellationToken cancellationToken)
at Microsoft.Graph.AuthenticationHandler.SendAsync(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Microsoft.Graph.HttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.Graph.HttpProvider.SendRequestAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Teamer.WebApi.Controllers.SubscriptionController.Register() in C:\Users\dave\source\repos\Dave\Teamer\Teamer.WebApi\Controllers\SubscriptionController.cs:line 40
Don't keep adding the authorization header but set it once. Happy to make the PR