microsoftgraph / microsoftgraph/msgraph-sdk-java

Authenticating using ConfidentialClient

Abierto
#2,468 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

status:waiting-for-triage
Lenguaje dominante
Java
Estrellas
444
Forks
154
Merge medio
18 h 28 min
PR fusionados (30 d)
4

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza comprobando si esta cuestión de autenticación de .NET pertenece al repositorio msgraph-sdk-java y, después, revisa la función GetAppAuthentication indicada y el enlace de disponibilidad de ConfidentialClientApplicationBuilder. Se considera terminado cuando se haya identificado por qué los escenarios Windows Service y WinForms reciben este error y se haya documentado o confirmado un enfoque compatible; no se menciona ningún archivo de proyecto ni ninguna prueba.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Área
authentication
Tipo de issue
Error
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
15/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.