0

WSO2 Identity Server 5.7.0 Revoke Method doesn't work resulting in Error Code : 401 -> UnAuthorize.

this link says how to use the revoke method, and I want use this for c# code:

    WebRequest request2 = WebRequest.Create("https://localhost:9443/oauth2/revoke?token=" + accessToken + "&token_type_hint=access_token");
    request2.Method = "POST";
    request2.PreAuthenticate = true;
    request2.Credentials = CredentialCache.DefaultCredentials;
    ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
    request2.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
    request2.Headers.Add("Authorization", "Basic " + "YFnfIeUVkpW64sSysLgoqajioOIa" + ":" + "L7rtcwWDqAQ6NdsvY2ZqUTAi5wMa");
    var response2 = request2.GetResponseAsync();
    response2.Wait();
    var t = response2.Result;
Community
  • 1
  • 1

1 Answers1

1

You have to basic 64 encode the <client id>:<client secret> value in the authorization header. Header should look like,

Authorization: Basic WUZuZkllVVZrcFc2NHNTeXNMZ29xYWppb09JYTogTDdydGN3V0RxQVE2TmRzdlkyWnFVVEFpNXdNYQ==

If you try the curl command in the document, --basic -u "<client id>:<client secret>" part will be doing the same thing and if you add -v option to the command you can see the actual header value sent with the curl request.

Maduranga Siriwardena
  • 1,341
  • 1
  • 13
  • 27