microsoftgraph / microsoftgraph/msgraph-sdk-java

Authenticating using ConfidentialClient

Aberta
#2,468 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

status:waiting-for-triage
Linguagem predominante
Java
Estrelas
444
Forks
154
Merge médio
18h 28min
PRs com merge (30d)
4

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece verificando se esta questão de autenticação do .NET pertence ao repositório msgraph-sdk-java e, em seguida, revise a função GetAppAuthentication relatada e o link de disponibilidade de ConfidentialClientApplicationBuilder. O trabalho estará concluído quando for identificado por que os cenários Windows Service e WinForms recebem este erro e uma abordagem com suporte for documentada ou confirmada; nenhum arquivo de projeto ou teste é mencionado.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Domínio
authentication
Tipo de issue
Bug
Dificuldade
5/5
Tempo estimado
Mais de uma semana
Status de atividade
Estagnada
Clareza
Precisa de esclarecimento
Facilidade para iniciantes
15/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.