mirror of
https://gitee.com/dcren/openiddict-documentation.git
synced 2025-07-15 23:13:34 +08:00
Update the documentation pages
This commit is contained in:
parent
4edb932430
commit
50fd5de866
@ -210,16 +210,16 @@ Here's an example for the client credentials grant:</p>
|
|||||||
var request = HttpContext.GetOpenIddictServerRequest();
|
var request = HttpContext.GetOpenIddictServerRequest();
|
||||||
if (!request.IsClientCredentialsGrantType())
|
if (!request.IsClientCredentialsGrantType())
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("The specified grant type is not implemented.");
|
throw new NotImplementedException("The specified grant is not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: the client credentials are automatically validated by OpenIddict:
|
// Note: the client credentials are automatically validated by OpenIddict:
|
||||||
// if client_id or client_secret are invalid, this action won't be invoked.
|
// if client_id or client_secret are invalid, this action won't be invoked.
|
||||||
|
|
||||||
var application = await _applicationManager.FindByClientIdAsync(request.ClientId);
|
var application = await _applicationManager.FindByClientIdAsync(request.ClientId);
|
||||||
if (application == null)
|
if (application is null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("The application details cannot be found in the database.");
|
throw new InvalidOperationException("The application details cannot be found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new ClaimsIdentity containing the claims that
|
// Create a new ClaimsIdentity containing the claims that
|
||||||
@ -229,13 +229,16 @@ Here's an example for the client credentials grant:</p>
|
|||||||
Claims.Name, Claims.Role);
|
Claims.Name, Claims.Role);
|
||||||
|
|
||||||
// Use the client_id as the subject identifier.
|
// Use the client_id as the subject identifier.
|
||||||
identity.AddClaim(Claims.Subject, await _applicationManager.GetClientIdAsync(application),
|
identity.AddClaim(Claims.Subject,
|
||||||
|
await _applicationManager.GetClientIdAsync(application),
|
||||||
Destinations.AccessToken, Destinations.IdentityToken);
|
Destinations.AccessToken, Destinations.IdentityToken);
|
||||||
|
|
||||||
identity.AddClaim(Claims.Name, await _applicationManager.GetDisplayNameAsync(application),
|
identity.AddClaim(Claims.Name,
|
||||||
|
await _applicationManager.GetDisplayNameAsync(application),
|
||||||
Destinations.AccessToken, Destinations.IdentityToken);
|
Destinations.AccessToken, Destinations.IdentityToken);
|
||||||
|
|
||||||
return SignIn(new ClaimsPrincipal(identity), OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
|
return SignIn(new ClaimsPrincipal(identity),
|
||||||
|
OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</code></pre></li>
|
</code></pre></li>
|
||||||
@ -254,7 +257,8 @@ Here's an example for the client credentials grant:</p>
|
|||||||
var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
await context.Database.EnsureCreatedAsync();
|
await context.Database.EnsureCreatedAsync();
|
||||||
|
|
||||||
var manager = scope.ServiceProvider.GetRequiredService<IOpenIddictApplicationManager>();
|
var manager =
|
||||||
|
scope.ServiceProvider.GetRequiredService<IOpenIddictApplicationManager>();
|
||||||
|
|
||||||
if (await manager.FindByClientIdAsync("console") is null)
|
if (await manager.FindByClientIdAsync("console") is null)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
"output": {
|
"output": {
|
||||||
".html": {
|
".html": {
|
||||||
"relative_path": "guide/getting-started.html",
|
"relative_path": "guide/getting-started.html",
|
||||||
"hash": "G5Z0qYgQEEbzw1G+VpiRHg=="
|
"hash": "x2y3JmMShZP8OKbVIkktGw=="
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is_incremental": false,
|
"is_incremental": false,
|
||||||
|
Loading…
Reference in New Issue
Block a user