【问题标题】:JWT bearer token flow with IdentityServer v3带有 IdentityServer v3 的 JWT 不记名令牌流
【发布时间】:2015-01-21 05:17:00
【问题描述】:

我希望为我的 web api 实现 OAuth2 授权,并使用 Google 的文档作为模型。我正在尝试实施的具体流程是“服务帐户”流程:here(据我了解,这也称为 JWT Bearer Token 流程?)。

如何在我的 MVC 应用程序中使用 Thinktecture 实现这一点? (或者有更好的选择吗?)

【问题讨论】:

    标签: .net oauth-2.0 thinktecture


    【解决方案1】:

    您应该能够使用与作为 v2 (https://github.com/thinktecture/Thinktecture.IdentityServer.v2/blob/master/samples/AdfsIntegrationSampleClient/AdfsIntegrationSampleClient/Program.cs#L123) 的一部分提供的示例中相同的代码,因此:

            var client = new HttpClient { BaseAddress = new Uri(idsrvEndpoint) };
    
            var values = new Dictionary<string, string>
            {
                { OAuth2Constants.GrantType, "urn:ietf:params:oauth:grant-type:jwt-bearer" },
                { OAuth2Constants.Assertion, jwt },
                { OAuth2Constants.Scope, realm }
            };
    
            var form = new FormUrlEncodedContent(values);
    
            var response = client.PostAsync("", form).Result;
            response.EnsureSuccessStatusCode();
    
            var tokenResponse = response.Content.ReadAsStringAsync().Result;
            var json = JObject.Parse(tokenResponse);
            return json["access_token"].ToString();
    

    【讨论】:

    • 这将是客户端应用程序从我的应用程序请求访问令牌,对吧?我实际上是在尝试找出服务器端(即 app.UseIdentityServer(......) )。这个问题有意义吗?
    • 这个问题有道理,但是我对那方面不熟悉,抱歉
    猜你喜欢
    • 2015-08-13
    • 2016-03-06
    • 2022-08-06
    • 2021-06-02
    • 2016-09-25
    • 2020-03-21
    • 2017-08-15
    • 2013-06-28
    • 2021-07-12
    相关资源
    最近更新 更多