skazantsev / WebDavClient

Asynchronous cross-platform WebDAV client for .NET Core
MIT License
160 stars 32 forks source link

MSAL claims based authentication not supported #60

Open Cpt-Falcon opened 4 years ago

Cpt-Falcon commented 4 years ago

In the web client params, we should be able to pass an AuthenticationHeaderValue to support MSAL, for example the following from the Microsoft MSAL tutorial

            httpClient.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue(Constants.BearerAuthorizationScheme,
                                              accessToken);

Currently this Web DAV Client does not support Microsoft sharepoint since I can't pass the needed access token as part of the header. I might add this in myself if it would be desired.

skazantsev commented 4 years ago

Hi @serp777 , It's possible to pass a custom HttpClient instance when creating WebDavClient.

WebDavClient CreateClientWithAuth(string accessToken)
{
    var httpClient = new HttpClient();
    httpClient.DefaultRequestHeaders.Authorization =
        new AuthenticationHeaderValue("Bearer", accessToken);
    return new WebDavClient(httpClient);
}

I hope it solves it.