1、Add BookStore_App section int BookStore.DbMigrator\appsettings.json "BookStore_App": { "ClientId": "BookStore_App", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44333" } 2、Add Client in BookStore.Domain\OpenIddict\OpenIddictDataSeedContributor.cs // BookStoreApp Client var bookStoreAppClientId = configurationSection["BookStore_App:ClientId"]; if (!bookStoreAppClientId.IsNullOrWhiteSpace()) { var bookStoreAppRootUrl = configurationSection["BookStore_App:RootUrl"]?.TrimEnd('/'); await CreateApplicationAsync( name: bookStoreAppClientId, type: OpenIddictConstants.ClientTypes.Confidential, consentType: OpenIddictConstants.ConsentTypes.Implicit, displayName: "BookStoreApp", scopes: commonScopes, grantTypes: [OpenIddictConstants.GrantTypes.Password,], secret: configurationSection["BookStore_App:ClientSecret"] ?? "1q2w3e*", redirectUri: $"{bookStoreAppRootUrl}/authentication/login-callback" ); } 3、Run DbMigrator project 4、Add ClientSecret to BookStore\test\BookStore.HttpApi.Client.ConsoleTestApp\appsettings.json { "RemoteServices": { "Default": { "BaseUrl": "https://localhost:44333" } }, "IdentityClients": { "Default": { "GrantType": "password", "ClientId": "BookStore_App", "UserName": "admin", "UserPassword": "1q2w3E*", "ClientSecret": "1q2w3e*", "Authority": "https://localhost:44333", "Scope": "BookStore" } } } 5、Run API and test again
- Add BookStore_App section int BookStore.DbMigrator\appsettings.json
"BookStore_App": { "ClientId": "BookStore_App", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44333" }
- Add Client in BookStore.Domain\OpenIddict\OpenIddictDataSeedContributor.cs
// BookStoreApp Client var bookStoreAppClientId = configurationSection["BookStore_App:ClientId"]; if (!bookStoreAppClientId.IsNullOrWhiteSpace()) { var bookStoreAppRootUrl = configurationSection["BookStore_App:RootUrl"]?.TrimEnd('/'); await CreateApplicationAsync( name: bookStoreAppClientId, type: OpenIddictConstants.ClientTypes.Confidential, consentType: OpenIddictConstants.ConsentTypes.Implicit, displayName: "BookStoreApp", scopes: commonScopes, grantTypes: [ OpenIddictConstants.GrantTypes.Password, ], secret: configurationSection["BookStore_App:ClientSecret"] ?? "1q2w3e*", redirectUri: $"{bookStoreAppRootUrl}/authentication/login-callback" ); }
-
Run DbMigrator project
-
Add ClientSecret to BookStore\test\BookStore.HttpApi.Client.ConsoleTestApp\appsettings.json
{ "RemoteServices": { "Default": { "BaseUrl": "https://localhost:44333" } }, "IdentityClients": { "Default": { "GrantType": "password", "ClientId": "BookStore_App", "UserName": "admin", "UserPassword": "1q2w3E*", "ClientSecret": "1q2w3e*", "Authority": "https://localhost:44333", "Scope": "BookStore" } } }
5 Run API and test again
标签:44333,ClientSecret,Consuming,HTTP,APIs,App,ClientId,BookStore,Client From: https://www.cnblogs.com/xinzheng/p/18386535