Search code examples
c#asp.net-coreidentityserver4bearer-token

Revoke token with identity server 4


Im trying to revoke token using identity server 4, i have only bearer token in my part of code, the problem is that i should use RevokeTokenAsync method, but this take more parameters tha ihave available :

public async void Logout(string bearerToken)
{
  var client = new HttpClient();

  // request token revocation
  var response = await client.RevokeTokenAsync(new TokenRevocationRequest
      {
        Address = uri,           
        ClientId = clientId,    // ?
        ClientSecret = key,     // ?
        Token = bearerToken
      });
   // manage errors ....      
}

Exist any other way to revocate the token without passing others parameters besides token?


Solution

  • When you are calling IdentityServer's endpoints, you should be authenticated for IdentityServer. So you have to pass those parameter with your request.

    No there is not any way for calling revoke endpoint without ClientId and ClientSecret.

    You can find your ClientId and ClientSecret in your IdentityServer's configuration.