我在互联网上尝试了各种解决方案,但所有解决方案都以不同的方式出现问题。我写这封信是希望 StackOverflow 上熟悉类似工作流程的人或来自 Microsoft.IdentityModel.JsonWebTokens 团队的人能够介入提供帮助。
我想要做的是解密由 JSONWebKey (JWK) 加密的 OAuth 访问令牌,以便我可以读取声明数据。现在我陷入了解密步骤。我在 OS X 上使用 C# 和 Visual Studio for Mac。我尝试过的方法包括使用旧的 JWT 库并尝试通过迂回方式创建各种 RSA 对象。但是,我想做的是如下所示:
using System;
using System.Linq;
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.IdentityModel.Tokens;
using System.Security.Cryptography;
using Microsoft.AspNetCore.WebUtilities;
namespace jwtdecoder {
class Program {
static void Main(string[] args) {
/* Exact string of a token retrieved from the IDP/OAuth server. */
String token = "BASE64EncodedTokenGoesHere";
/* Trust me that we have a valid JWKS string here that has all the properties mentioned …Run Code Online (Sandbox Code Playgroud)