Forum Discussion
Authenticating using ConfidentialClient
Hello,
Some of our customers are unable to send out automated emails because support for basic authentication with SMTP is being removed.
I am looking at finding a solution and it seems the Graph API is the recommended approach.
I have manage to create a working example using `PublicClientApplicationBuilder` however, this class displays a pop-up requiring the user to sign in, since we have automated services with no user interaction, this is not a good solution.
I have seen some examples using `ConfidentialClientApplicationBuilder` and this seems idea.
However, I have reached multiple dead-ends and everytime receive the error:
> Confidential Client flows are not available on mobile platforms or on Mac.See https://aka.ms/msal-net-confidential-availability for details.
Please would someone be able to help me. Why do I recieve this error? Whatever I do, whatever project I use, WinForm, Console app and Service I always get this error.
I am storing my Client, Tenant and Secret in a database table and here is my code:
``` vb
Private Async Function GetAppAuthentication() As Task(Of AuthenticationResult)
Dim folderAccess = BLL.L2S.SystemApplicationGateway.GetFolderAccess(mBLL_SY.ReadonlyDbContext)
If folderAccess Is Nothing Then
Return Nothing
End If
Dim app = ConfidentialClientApplicationBuilder.Create(folderAccess.Client) _
.WithClientSecret(folderAccess.Secret) _
.WithTenantId(folderAccess.Tenant) _
.Build()
Dim scopes As String() = {"https://outlook.office365.com/.default"}
Dim result As AuthenticationResult = Await app.AcquireTokenForClient(scopes).ExecuteAsync()
Return result
End Function
```
I am using .Net Framework 4.7.2, we have Windows Services and WinForms apps and both need to send out emails.
The error message is very confusing to me because of course it is not a mobile app, and I have even created a UnitTest that seemingly works fine which again is very confusing to me.
This is urgent as this is already causing issues for our customers.
Thanks in advanc