microsoftgraph / microsoftgraph/msgraph-sdk-java

Authenticating using ConfidentialClient

オープン
#2,468 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

status:waiting-for-triage
主要言語
Java
スター
444
フォーク
154
平均マージ
18時間 28分
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

.NET 認証に関するこの質問が msgraph-sdk-java リポジトリに属するかどうかをまず確認し、その後、報告されている GetAppAuthentication 関数と ConfidentialClientApplicationBuilder の利用可能性リンクを確認します。Windows Service および WinForms のシナリオでこのエラーが発生する理由を特定し、サポートされているアプローチを文書化または確認できれば完了です。プロジェクト ファイルやテストは指定されていません。

索引モデルが issue の本文から書いたものです。

評価

領域
authentication
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
15/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。