1

我正在使用VS 2015通過Azure AD身份驗證創建新的Web應用程序(.NET核心)。運行應用後,我看到Azure AD會自動爲我註冊新應用。然後,我可以用我的Azure用戶成功登錄。手動在Azure AD中註冊新應用程序

但我想手動註冊我的應用程序。因此,我跟着這個網站上說明: https://docs.microsoft.com/en-us/azure/active-directory/active-directory-app-registration

然後註冊我的手動新的應用程序在Azure AD,然後更新生成的客戶端ID來我appsettings.json,然後運行,並與Azure的用戶登錄。我得到的錯誤信息:

An unhandled exception occurred while processing the request. 

HttpRequestException: Response status code does not indicate success: 401 (Unauthorized). 
MoveNext 

AggregateException: Unhandled remote failure. (Response status code does not indicate success: 401 (Unauthorized).) 
MoveNext 

一些專家可以讓我知道原因嗎?我是Azure的新手。 還有一個問題是我不知道爲什麼在我的appsetting.json文件中沒有SecretKey?

This is the screen when I created the app

This is my appsetting.json file

回答

1

當您將appsettings.json更改爲第二個應用程序時,此問題會導致應用程序的客戶端密碼不正確。

的敏感數據被存儲在所述用戶簡檔目錄中的JSON配置文件:

視窗:%APPDATA%\微軟\ UserSecrets \\ secrets.json

的Linux:〜/。微軟/ usersecrets //secrets.json

的Mac:〜/。微軟/ usersecrets // secrets.json

後您chagne ClientSecret在secrets.json,應用程序應該效果很好。

有關在開發過程中安全存儲應用程序祕密的更多詳細信息,請參閱here

+0

現在它工作,我明白了。謝謝費雪,你很高明。 – amzdmt

0

你可能缺少一些代表團權利(申請權)。可能爲Graph Api

由於您使用Azure帳戶登錄,因此應用程序會向e執行請求。 G。圖表Api代表你的用戶(這就是爲什麼你必須設置授權)。這也是您不需要ClientSecret的原因(如果您的應用程序使用服務負責人進行身份驗證,則需要這樣做)。

+0

感謝馬丁的迴應。其實我爲2個應用程序配置相同,包括ReplyURLs,Required Permission(使用2刪除權限:登錄和讀取用戶配置文件,讀取目錄數據)。問題出在我更改爲第二次應用程序註冊後,Web應用程序再次導航到「同意」頁面,然後單擊「接受」按鈕時出現上述錯誤。 – amzdmt