我已經設置了一個在IIS中運行的IdentityServer3實例。IdentityServer3 PostMan invalid_client
var validators = new List<Registration<ISecretValidator>>
{
new Registration<ISecretValidator, HashedSharedSecretValidator>(),
new Registration<ISecretValidator, X509CertificateThumbprintSecretValidator>()
};
// .Register() is an extension method that setups that setups the
// IdentityServerServiceFactory
var factory = new EntityFrameworkServiceOptions()
.Register()
.UseInMemoryUsers(Users.Get());
factory.SecretValidators = validators;
app.Map($"/{IdentityServer.Path}", server =>
{
server.UseIdentityServer(new IdentityServerOptions()
{
RequireSsl = false,
SiteName = siteName,
SigningCertificate = Certificate.Load(),
Factory = factory,
// Currently does nothing. There are no plugins.
PluginConfiguration = ConfigurePlugins,
AuthenticationOptions = new AuthenticationOptions()
{
EnablePostSignOutAutoRedirect = true,
// Currently does nothing. There are no IdentityProviders setup
IdentityProviders = ConfigureIdentityProviders
}
});
});
我已經在客戶端憑證流程的EF數據庫中設置了一個客戶端。因此,在Client
表中有一個客戶端,我已向客戶端訪問ClientScopes
表中的範圍,並且我已在ClientSecrets
表中爲客戶端提供了一個祕密。
存儲在數據庫中的相關值(未列出的所有值都是IdentityServer3默認):
ClientId = 'client'
Flow = 'ClientCredentials [3]'
ClientScope = 'api'
ClientSecret = 'secret'.Sha256()
IdentityServer正在測試服務器上運行,這就是爲什麼我沒有選擇「本地請求訪問令牌」的原因。
當我點擊「請求令牌」我收到以下錯誤記錄:
2016-09-16 16:18:28.470 -05:00 [Debug] Start client validation
2016-09-16 16:18:28.470 -05:00 [Debug] Start parsing Basic Authentication secret
2016-09-16 16:18:28.470 -05:00 [Debug] Parser found secret: "BasicAuthenticationSecretParser"
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] Secret id found: "client"
2016-09-16 16:18:28.470 -05:00 [Debug] No matching hashed secret found.
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] Secret validators could not validate secret
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] Client validation failed.
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] End token request
w3wp.exe Information: 0 : 2016-09-16 16:18:28.470 -05:00 [Information] Returning error: invalid_client
我真的不知道爲什麼驗證無法驗證的祕密。它被保存在數據庫中,Sha256和IdentityServer可以解析和驗證Sha256。
UPDATE: 我得到它的工作做從郵遞員POST,並填寫相應的X WWW的形式,進行了urlencoded領域,但我還沒有想出如何得到它的使用授權工作標籤和Postman的「獲取新訪問令牌」功能。不能用於從IdentityServer3獲取令牌嗎?
我將回調URL添加到客戶端的重定向uris。我將我的令牌名稱更新爲「承載者」。我將Auth網址更改爲授權終點。 (我的授權類型仍然是Client Credentials)。我在本地檢查了請求訪問令牌複選框,並且仍然使用此方法得到「invalid_client」...客戶端是否必須使用「授權碼」流設置? –
我已經使用客戶端證書和資源代碼來完成它的工作。唯一的區別是資源代碼郵差會彈出一個登錄對話框。這對於我工作的開發很方便,因爲大量REST服務調用需要與特定用戶關聯。 – GlennSills