I'm using the refresh token flow and it's working as designed where I can get a refresh token and then use it to get a new access token.
When the new access token is generated on the refresh token call I want to access the OpenIddictTokens.Id of the newly generated access token.
I thought I could do this using the OpenIddictServerEvents.ApplyTokenResponseContext event as shown below, but the Principal returned is null, so I can't get at the Token Id.
I have tried a bunch of other Server and Validation events, but can't seem to find an event which will allow me to get the token id of the new access token. Am I missing something?
.AddServer(options =>
{
....
options
.AllowClientCredentialsFlow()
// .AllowAuthorizationCodeFlow()
// .RequireProofKeyForCodeExchange()
.AllowRefreshTokenFlow();
options.AddEventHandler<OpenIddictServerEvents.ApplyTokenResponseContext>(builder =>
builder.UseInlineHandler(
context =>
{
var principal = context.Principal; //Principal is null
principal.GetTokenId();
return default;
})
);
I have tried a bunch of other Server and Validation events, but can't seem to find an event which will allow me to get the token id of the new access token. Am I missing something?
You can use the ProcessSignIn
event that has a RefreshTokenPrincipal
. Just make sure to register your event handler with a high order to ensure the token identifier is attached to the principal before your handler is invoked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.