Playframework 2.0 Securesocial,身份验证后调用linkedin请求时出现问题
我正在尝试使用securesocial通过OAuth1对Linkedin进行身份验证,并获取所连接用户的连接列表 身份验证工作正常,但在用户连接后调用任何请求都将返回401响应。 我可能做错了,但我看不出潜在的问题 下面是添加到securesocial代码中提供的Java演示应用程序的一个简单方法:Playframework 2.0 Securesocial,身份验证后调用linkedin请求时出现问题,playframework-2.0,linkedin,securesocial,Playframework 2.0,Linkedin,Securesocial,我正在尝试使用securesocial通过OAuth1对Linkedin进行身份验证,并获取所连接用户的连接列表 身份验证工作正常,但在用户连接后调用任何请求都将返回401响应。 我可能做错了,但我看不出潜在的问题 下面是添加到securesocial代码中提供的Java演示应用程序的一个简单方法: @SecureSocial.SecuredAction ( authorization = WithProvider.class, params = {"linkedin"}) public sta
@SecureSocial.SecuredAction ( authorization = WithProvider.class, params = {"linkedin"})
public static Result linkedinConnections(){
Identity user = (Identity) ctx().args.get(SecureSocial.USER_KEY);
OAuth1Info oauthInfo = user.oAuth1Info().get();
String url = "http://api.linkedin.com/v1/people/~/connections:(headline,first-name,last)?format=json";
String consumerKey = SecureSocial.serviceInfoFor(user).key().key();
String consumerSecret = SecureSocial.serviceInfoFor(user).key().secret();
return async(
WS.url(url)
.sign(
new OAuthCalculator(
new OAuth.ConsumerKey(consumerKey, consumerSecret),
new OAuth.RequestToken(oauthInfo.token().toString(), oauthInfo.secret().toString())
)
)
.get()
.map(new Function<WS.Response, Result>() {
public Result apply(WS.Response response) {
System.out.println(response);
return ok(response.getStatusText());
}
})
);
}
@SecureSocial.SecuredAction(authorization=WithProvider.class,params={“linkedin”})
公共静态结果linkedinConnections(){
Identity user=(Identity)ctx().args.get(SecureSocial.user_KEY);
OAuth1Info oauthInfo=user.OAuth1Info().get();
字符串url=”http://api.linkedin.com/v1/people/~/connections:(标题、名字、姓氏)?格式=json”;
字符串consumerKey=SecureSocial.serviceInfoFor(user.key().key();
字符串consumerSecret=SecureSocial.serviceInfoFor(user.key().secret();
异步返回(
url(url)
.签名(
新OAuthCalculator(
新OAuth.ConsumerKey(ConsumerKey,ConsumerCret),
新的OAuth.RequestToken(oauthInfo.token().toString(),oauthInfo.secret().toString())
)
)
.get()
.map(新函数(){
应用公共结果(WS.Response响应){
System.out.println(响应);
返回ok(response.getStatusText());
}
})
);
}
任何想法都会有帮助
问候,,
Nabil我没有尝试将SecureSocial与LinkedIn一起使用,但考虑到这一点
- 社会工作认证
- 您想列出LinkedIn用户的连接
- 您自己的方法总是会出现401错误(未经授权)