Getting access to decoded JWT in ASP.NET Core 3.1

Hi there

I have an ASP.NET Core 3.1 backend using SignalR to communicate with clients, rather than ASP.NET Core controllers. I am struggling to get access to the JWT, in particular, the sub from the JWT which I need. The example code given for an ASP.NET Core app doesn’t include accessing the sub from the JWT, although the quickstart includes a folder 01 - authorization, which gives me hope that there’s a subsequent example with some more juicy goodness. Am I right in thinking this?

In any event, perhaps I should start from the basics. How do I access the sub from the JWT in ASP.NET Core 3.1 controllers? Perhaps then I will have a better idea of how I’m going to access them from within my SignalR hubs.

I created a Stackoverflow post for this issue here: c# - Auth0, .NETCoreApp 3.1 and SignalR: obtaining decoded JWT - Stack Overflow

Any help greatly appreciated!

Mark

Hi @mark.norgate1,

Welcome back to the Community!

Have you looked at our API docs that show how to decode a token? It looks like there is an example of getting the sub claim in there too.

Let me know if it helps,
Dan

Hi there Dan

I don’t really know how or why, but I just tried to run my app again after reading through your post, and it is now working. Perhaps because now I am using Context.UserIdentidier rather than Context.User.

Anyway, it’s working now and I’m happy again, so thank you!

Mark

1 Like

Glad it was solved! Let us know if you have any other questions.

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