microsoftgraph / microsoftgraph/msgraph-sdk-java

Authenticating using ConfidentialClient

未關閉
#2,468 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

status:waiting-for-triage
主要語言
Java
星號
444
分支
154
平均合併
18 小時 28 分鐘
30 天內合併 PR
4

描述

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.

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先確認這個 .NET 驗證問題是否屬於 msgraph-sdk-java 儲存庫,然後檢視所回報的 GetAppAuthentication 函式和 ConfidentialClientApplicationBuilder 可用性連結。完成的定義是找出 Windows Service 和 WinForms 情境收到此錯誤的原因,並記錄或確認受支援的方法;未指定任何專案檔案或測試。

由索引模型根據 Issue 內容生成。

評估

領域
authentication
Issue 類型
缺陷
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
15/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。