【问题标题】:Fetching Access token using Auth token from service in C#使用 C# 中的服务中的 Auth 令牌获取访问令牌
【发布时间】:2014-07-08 11:20:06
【问题描述】:

我是 Oauth 和加密主题的新手。我需要编写一个实用程序,其中我有 authtoken,并且在调用服务 url 说 xyzcorp.com 后我需要获取访问令牌。我已经有了身份验证令牌,我需要使用 post 方法对 url 进行服务调用,然后返回访问令牌。我找不到任何代码 sn-p 显示这是如何完成的。正如我已经说过的,我是这个领域的新手,对 c# 中的实现一无所知。需要注意的是,我只有身份验证令牌。

【问题讨论】:

    标签: c# oauth access-token auth-token


    【解决方案1】:

    您使用的是什么 C# 库?我使用了 Thinktecture.IdentityModel: https://github.com/thinktecture/Thinktecture.IdentityModel

    这是我的 OAuth2 Test Client 中使用 IdentityModel 的示例:

    private static async Task<TokenResponse> SendTokenRequest(string authCode, string redirectUri)
        {
            var tokenclient = new OAuth2Client(
                new Uri(Constant.TokenEndpoint),
                Constant.CodeClientId,
                Constant.CodeClientSecret);
    
    
            return await tokenclient.RequestAuthorizationCodeAsync(authCode, redirectUri);
        }
    

    【讨论】:

      猜你喜欢
      • 2015-07-19
      • 2014-08-04
      • 1970-01-01
      • 2022-06-19
      • 2018-02-17
      • 2013-08-17
      • 2017-12-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多