【发布时间】:2015-11-10 12:24:53
【问题描述】:
我正在为我们的 Web 应用程序中的用户授权 LinkedIn 应用程序。在基础上,它在 .NET 4.5.2 上使用带有 .NET Web api 后端的 angularjs。
在回调之前我确实让它工作了。代码如下:
public string GetAuthenticationUrl(string context, string redirectUrl)
{
if(context == null)
throw new ArgumentException(nameof(context));
if (string.IsNullOrEmpty(redirectUrl))
throw new ArgumentException(nameof(redirectUrl));
var appContext = _applicationContextProvider.GetLinkedInApplicationContext();
var linkedIn = new UserAgentClient(new AuthorizationServerDescription
{
TokenEndpoint = new Uri(appContext.AccessTokenEndpoint),
AuthorizationEndpoint = new Uri(appContext.AuthorizationEndpoint),
ProtocolVersion = ProtocolVersion.V20
}, appContext.ClientId, appContext.ClientSecret);
var target = linkedIn.RequestUserAuthorization(null, context, new Uri(redirectUrl));
return target.AbsoluteUri;
}
它返回一个我可以用来访问 LinkedIn 的 Url。 我授权应用程序并成功重定向到我的 redirectUrl,我在其中获得代码和状态。
但是接下来我该怎么做才能请求访问令牌?
public void Confirm(string state, string code)
{
// ?
}
我使用 dotnetopenauth 4.3
最好的问候 乔纳斯
【问题讨论】:
标签: oauth-2.0 linkedin dotnetopenauth