mirror of
https://gitee.com/dcren/openiddict-documentation.git
synced 2025-04-24 18:04:57 +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();
|
||||
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:
|
||||
// if client_id or client_secret are invalid, this action won't be invoked.
|
||||
|
||||
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
|
||||
@ -229,13 +229,16 @@ Here's an example for the client credentials grant:</p>
|
||||
Claims.Name, Claims.Role);
|
||||
|
||||
// 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);
|
||||
|
||||
identity.AddClaim(Claims.Name, await _applicationManager.GetDisplayNameAsync(application),
|
||||
identity.AddClaim(Claims.Name,
|
||||
await _applicationManager.GetDisplayNameAsync(application),
|
||||
Destinations.AccessToken, Destinations.IdentityToken);
|
||||
|
||||
return SignIn(new ClaimsPrincipal(identity), OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
|
||||
return SignIn(new ClaimsPrincipal(identity),
|
||||
OpenIddictServerAspNetCoreDefaults.AuthenticationScheme);
|
||||
}
|
||||
}
|
||||
</code></pre></li>
|
||||
@ -254,7 +257,8 @@ Here's an example for the client credentials grant:</p>
|
||||
var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
await context.Database.EnsureCreatedAsync();
|
||||
|
||||
var manager = scope.ServiceProvider.GetRequiredService<IOpenIddictApplicationManager>();
|
||||
var manager =
|
||||
scope.ServiceProvider.GetRequiredService<IOpenIddictApplicationManager>();
|
||||
|
||||
if (await manager.FindByClientIdAsync("console") is null)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@
|
||||
"output": {
|
||||
".html": {
|
||||
"relative_path": "guide/getting-started.html",
|
||||
"hash": "G5Z0qYgQEEbzw1G+VpiRHg=="
|
||||
"hash": "x2y3JmMShZP8OKbVIkktGw=="
|
||||
}
|
||||
},
|
||||
"is_incremental": false,
|
||||
|
Loading…
Reference in New Issue
Block a user