# Validate JWT in C#

**URL:** <https://community.auth0.com/t/validate-jwt-in-c/105240>\
**Category:** Get Help\
**Tags:** connection-provisioning-flows, connections\
**Created:** [April 21, 2023, 12:47pm UTC](https://community.auth0.com/t/validate-jwt-in-c/105240 "2023-04-21T12:47:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotaolaoqua](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dotaolaoqua](https://community.auth0.com/u/dotaolaoqua)\
**Post date:** [April 21, 2023, 12:47pm UTC](https://community.auth0.com/t/validate-jwt-in-c/105240/1 "2023-04-21T12:47:28Z")

</div>

Hi,

Is it possible to get the JWT and validate it after login?  
I’m using [ASP.NET](http://ASP.NET) Owin in C#  
Please help.

Thank you

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [April 21, 2023, 5:39pm UTC](https://community.auth0.com/t/validate-jwt-in-c/105240/3 "2023-04-21T17:39:52Z")

</div>

Hi @dotaolaoqua,

Thanks for reaching out to the Auth0 Community!

> [@dotaolaoqua](#):
>
> Is it possible to get the JWT and validate it after login?  
> I’m using [ASP.NET](http://ASP.NET) Owin in C#

Yes, this is possible. Once you have gotten the JWT access token, you can decode it to see if it is valid by checking the structure, claims, and signature.

There is also an option to use the access token to make a call to a protected resource to see if it succeeds or fails. If it succeeds, we can conclude that the JWT access token is valid, and invalid otherwise.

I recommend reviewing our [Validate Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/validate-access-tokens) documentation which has more instructions on these steps.

Please let me know if you have any questions or need help with implementation.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![dotaolaoqua](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dotaolaoqua](https://community.auth0.com/u/dotaolaoqua)\
**Post date:** [April 24, 2023, 4:26pm UTC](https://community.auth0.com/t/validate-jwt-in-c/105240/4 "2023-04-24T16:26:46Z")

</div>

Hi Rueben,

Thank you for your answer.  
Can you help me to implement it? This is what I did so far to get the JWT access token. I’m not sure what to do next to validate it. And which secret key should I use?  
Thank you for your help!

```auto
var client = new RestClient("https://dev-3gbtj2ssweblabla.us.auth0.com/oauth/token");
                                var request = new RestRequest(Method.POST);
                                request.AddHeader("content-type", "application/x-www-form-urlencoded");
                                request.AddParameter("application/x-www-form-urlencoded", "grant_type=client_credentials&client_id="+ ClientIdApp + "&client_secret="+ ClientSecretKeyApp + "&audience=https%3A%2F%2Fdev-3gbtj2ssweblabla.us.auth0.com%2Fapi%2Fv2%2F", ParameterType.RequestBody);
                                IRestResponse response = client.Execute(request);
                                string content = response.Content;
                                dynamic jsonObj = JsonConvert.DeserializeObject(content);
                                string accessToken = jsonObj.access_token;

```

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [April 25, 2023, 3:40am UTC](https://community.auth0.com/t/validate-jwt-in-c/105240/5 "2023-04-25T03:40:49Z")

</div>

Hi @dotaolaoqua,

Thank you for your response!

> [@dotaolaoqua](#):
>
> This is what I did so far to get the JWT access token. I’m not sure what to do next to validate it. And which secret key should I use?

That looks good, I see that you are making a Client Credentials grant call to generate an access token.

You should use the **client\_id** and **client\_secret** values from your Machine-to-Machine app that was created and linked to your API with the necessary permissions.

After you have gotten the access token in the response, you can validate it by decoding the token on [jwt.io](http://jwt.io). Similarly, you can use one of the [JSON Web Token Libraries - jwt.io](https://jwt.io/libraries) as well to accomplish this.

I recommend checking out this repository [here](https://github.com/jwt-dotnet/jwt) for an example.

In the decoded token result, you should be able to see the payload and validate the information by looking at the structure, claims, and signature.

I hope the explanation was clear!

Please let me know how this goes for you.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [May 9, 2023, 3:41am UTC](https://community.auth0.com/t/validate-jwt-in-c/105240/6 "2023-05-09T03:41:17Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
