diff --git a/src/IdentityServer/Stores/Default/DefaultUserConsentStore.cs b/src/IdentityServer/Stores/Default/DefaultUserConsentStore.cs index 5dab9f5ec..bb98ef06b 100644 --- a/src/IdentityServer/Stores/Default/DefaultUserConsentStore.cs +++ b/src/IdentityServer/Stores/Default/DefaultUserConsentStore.cs @@ -71,8 +71,11 @@ public async Task GetUserConsentAsync(string subjectId, string clientId { var legacyKey = GetConsentKey(subjectId, clientId, useHexEncoding: false); consent = await GetItemAsync(legacyKey); - await StoreUserConsentAsync(consent); // Write back the consent record to update its key - await RemoveItemAsync(legacyKey); + if(consent != null) + { + await StoreUserConsentAsync(consent); // Write back the consent record to update its key + await RemoveItemAsync(legacyKey); + } } return consent;