自定义流程 - 委托

Ped*_*ino 4 openiddict

我想知道是否可以使用openiddict类似于此处使用Identity Server.

var result = await _validator.ValidateAccessTokenAsync(userToken);
if (result.IsError)
{
    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant);
    return;
}
Run Code Online (Sandbox Code Playgroud)

是否有任何等效的方法来ValidateAccessTokenAsync验证openiddict令牌并访问其某些属性?

Kév*_*let 5

标准代币交换的实施由https://github.com/openiddict/openiddict-core/issues/1249跟踪。

同时,您可以覆盖默认ValidateTokenParameter处理程序以使用您的自定义授权,并从您使用的客户参数中提取访问令牌:

https://github.com/openiddict/openiddict-core/blob/422d8979adb8cdebc6c8c8e14faa1d736208271e/src/OpenIddict.Server/OpenIddictServerHandlers.cs#L168

然后,您可以IOpenIddictServerDispatcher.DispatchAsync()使用 的实例调用该方法ProcessAuthenticationContext来触发身份验证事件。如果IsRejectedtrue,则意味着令牌无效。否则,您将能够访问其声明主体。