我正在使用IdentityServer4软件包的1.0.0版本.
"IdentityServer4": "1.0.0"
Run Code Online (Sandbox Code Playgroud)
我创建了一个客户端
new Client
{
ClientId = "MobleAPP",
ClientName = "Moble App",
ClientUri= "http://localhost:52997/api/",
AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
ClientSecrets =
{
new Secret("SecretForMobleAPP".Sha256())
},
AllowedScopes =
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
"api"
},
AllowOfflineAccess = true
}
Run Code Online (Sandbox Code Playgroud)
和范围/ ApiResources
public static IEnumerable<ApiResource> GetApiResources()
{
return new List<ApiResource>
{
new ApiResource("api", "My API")
};
}
Run Code Online (Sandbox Code Playgroud)
使用以下用户/ TestUser
public static List<TestUser> GetUsers()
{
return new List<TestUser>
{
new TestUser
{
SubjectId = "2",
Username = "bob",
Password = "password",
Claims = new [] …Run Code Online (Sandbox Code Playgroud)