需要您的幫助解決以下問題。我在.netcore在VS2017創建的WebAPI,我試圖使用身份驗證的新模式https://apps.dev.microsoft.com/。ASP.NET核心WebAPI中的AAD V2與JwtBearer
我註冊了應用程序,創建應答網址https://localhost:44337/signin-oidc
在.netcore我有以下配置
"Authentication": {
"AzureAd": {
"AADInstance": "https://login.microsoftonline.com/",
"Audience": "<my audience>/<Name Of The App Registered>",
"ClientId": "<Registered App ID>",
"Domain": "<Domain of AAD>",
"TenantId": "<Tenant ID of AAD>"
}
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
現在我有一個通用的應用程序進行測試,但,每當試圖登錄後,總是給我這個錯誤:
Additional technical information:
Correlation ID: a14b452f-457a-46e6-9601-67383df6ba1a
Timestamp: 2017-05-11 09:42:56Z
AADSTS50011: The reply address 'urn:ietf:wg:oauth:2.0:oob' does not match the reply addresses configured for the application: '<My Application ID>'. More details: not specified
我已經確認的AppID在apps.dev.microsoft.com,我也註冊了應用程序在AAD(具有不同的ID,I C ANNOT控件)
這是Startup.cs的代碼:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
Authority = Configuration["Authentication: AzureAd:AADInstance"] + Configuration["Authentication: AzureAd:TenantId"],
Audience = Configuration["Authentication:AzureAd:Audience"],
TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters
{
ValidIssuer = Configuration["Authentication: AzureAd:AADInstance"] + Configuration["Authentication: AzureAd:TenantId"] + "/ v2.0"
}
});
app.UseMvc();
}
預先感謝您的幫助,
比方說,我想和郵遞員訪問,或者我發佈應用程序到雲中的任何人使用(因爲這是返回JSON數據的WebAPI)。我想我不需要註冊所有可以訪問我的WebAPI的應用程序,對吧?或者任何將使用我的webapi的應用程序都必須註冊?我需要做些什麼來避免這種情況? – HLourenco
就你而言,你有一個UWP應用程序。 AFAIK,UWP應用程序無法接收登錄到API時發送到https:// localhost:44337/signin-oidc的令牌。這就是爲什麼你必須註冊一個本地應用程序,並授予API的權限。 –
嗨馬丁,我已經有機會獲得郵差的信息,所以,如果我插入的郵遞員與https://login.microsoftonline.com/ /的oauth2 /配置授權資源= HTTPS://前景。 com /我有一個有效的令牌迴應,但不能在我的請求中使用。如果我使用https://login.microsoftonline.com/ /oauth2/authorize?resource = https:// localhost:44337 /或任何其他頁面,它會向我打開一個沒有任何令牌的黑色頁面。我應該在我的webapi上丟失一些部分嗎? –
HLourenco