【问题标题】:Authorization from C# with auth2 and linkedin使用 auth2 和 linkedin 从 C# 授权
【发布时间】:2016-09-03 17:23:13
【问题描述】:

我有一个 WebApi,我想用他的链接信息授权我的用户(如创建访问令牌并将其注入我的 owin)。

到目前为止,我已经尝试与 Sparkle.Linkedin 合作,这就是我所拥有的

public LinkedInLogic() {
    // create a configuration object
    _config = new LinkedInApiConfiguration(ApiKey, ApiSecret);
    // get the APIs client
    _api = new LinkedInApi(_config);
 }

 public Uri GetAuthUrl() {
     var scope = AuthorizationScope.ReadBasicProfile;
     var state = Guid.NewGuid().ToString();
     var redirectUrl = "http://localhost:1510/api/login/RedirectAuth";
     return _api.OAuth2.GetAuthorizationUrl(scope, state, redirectUrl);
 }

 public void GetAccessToken(string code) {
     //If I do api.GetAccessToken(code); here I get an access token
     var request = System.Net.WebRequest.Create("http://localhost:1510/api/token?grant_type=authorization_code&code=" + code);
     request.GetResponse(); // my owin authorization
 }

所以我首先获得授权网址 -> 它会打开一个弹出窗口 -> 我输入我的数据,然后它会返回到启动 GetAccessToken 的控制器。

问题是即使我完全使用linkedin 进行授权,我也不确定如何使用我自己的webapi 进行授权。所以我尝试向我的 owin 令牌提供者发送一个 http 请求,但它不喜欢它。似乎也没有,我可以将访问令牌返回给用户,以便他可以在他的会话中使用它。

有什么想法吗?

【问题讨论】:

    标签: c# asp.net-web-api oauth-2.0 authorization linkedin


    【解决方案1】:

    不太确定自从 Linkedin 于 2015 年 5 月做出更改后,火花是否已经起作用了

    【讨论】:

      猜你喜欢
      • 2011-10-17
      • 1970-01-01
      • 2011-12-07
      • 1970-01-01
      • 2015-07-24
      • 2020-09-20
      • 1970-01-01
      • 1970-01-01
      • 2019-09-02
      相关资源
      最近更新 更多