Identityserver4: Cannot implicitly convert type 'ICollection<IdentityServer4.Models.ClientClaim>

Created on 29 Jun 2020  路  3Comments  路  Source: IdentityServer/IdentityServer4

Question

Hello,

I just updated my Idsr4 to version 4.0.0 and I have a type conversion problem in my ClientRequestValidator.

I want to recover the claims of a client with the FindClientByIdAsync method but since the update the type has changed.

private async Task<IEnumerable<Claim>> GetClaimsFromClient(string clientId)
        {
            var client = await _clientStore.FindClientByIdAsync(clientId);

            if (client is null)
            {
                throw new Exception();
            }

            return client.Claims;
        }

Here is the error:

image

Do you have the solution to this problem?

Thank you

question

All 3 comments

In this case, it's true that it's not practical that the types are different.

As an acceptable workaround you can do :

return client.Claims.Select(c => new Claim(c.Type, c.Value, c.ValueType));

Perfect, thank you, I had found another solution but this one suits me better.

I close my issue ;)

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eshorgan picture eshorgan  路  3Comments

ekarlso picture ekarlso  路  3Comments

createroftheearth picture createroftheearth  路  3Comments

osmankibar picture osmankibar  路  3Comments

leastprivilege picture leastprivilege  路  3Comments