Validate Opaque User Id or helixToken for security in websocket message processing?

I’ll go ahead and mark this as solved since testing the code I posted above has gone well and I havent needed to make any more changes to avoid exceptions or other issues.

If anyone else is doing this sort of thing in C# in the future the biggest thing I had as a stumbling block was getting the payload data out of the validated token.

After you call:

tokenHandler.ValidateToken(tokenStr, tokenParameters, out validatedToken);

The validatedToken you get shows all the data in the debugger, but the object itself does not present the properties you expect.

((JwtSecurityToken)validatedToken).Payload.TryGetValue(“channel_id”,out var tokenChannelId)

Apparently the validateTokens method requires the out parameter to be of type SecurityToken but the object has data as if it is a JwtSecurityToken and you need to cast it that way to access things like the Payload. That in itself took a while to get working, the rest of it was pretty much just following the documentation.