microsoftgraph / microsoftgraph/msgraph-sdk-java

Authenticating using ConfidentialClient

Aperta
#2,468 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

status:waiting-for-triage
Lingua principale
Java
Stelle
444
Fork
154
Merge medio
18h 28m
PR unite (30g)
4

Descrizione

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.

I understand that it is limeted by design (see issues/742) but ConfidentialClientApplicationBuilder throws this issue for every project type I try, WinForm, Windows Service, Console app.
I have got it working on a ASP controller but they is not practicable for our customer.
I am storing my Client, Tenant and Secret in a database table and here is my code:

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 advance.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia verificando se questa domanda sull'autenticazione .NET appartiene al repository msgraph-sdk-java, quindi esamina la funzione GetAppAuthentication segnalata e il link sulla disponibilità di ConfidentialClientApplicationBuilder. Il lavoro è completato quando viene identificato il motivo per cui gli scenari Windows Service e WinForms ricevono questo errore e viene documentato o confermato un approccio supportato; non vengono indicati file di progetto né test.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Ambito
authentication
Tipo di issue
Bug
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
15/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.