为什么 Socialauth 在提供的参数映射上给出类转换异常?
SocialAuth 入门指南有以下代码示例:
// get the auth provider manager from session
SocialAuthManager manager = (SocialAuthManager)session.getAttribute("authManager");
// call connect method of manager which returns the provider object.
// Pass request parameter map while calling connect method.
AuthProvider provider = manager.connect(paramsMap);
// get profile
Profile p = provider.getUserProfile();
// you can obtain profile information
System.out.println(p.getFirstName());
// OR also obtain list of contacts
List<Contact> contactsList = provider.getContactList();
第 3-4 行的评论说我们应该将请求参数映射传递给manager.connect()。我尝试过:
manager.connect(request.getParameterMap());
但它给出了
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String
我应该创建自己的参数映射而不是传递 request.getParameterMap()
返回的映射吗?
SocialAuth getting started guide have following code sample:
// get the auth provider manager from session
SocialAuthManager manager = (SocialAuthManager)session.getAttribute("authManager");
// call connect method of manager which returns the provider object.
// Pass request parameter map while calling connect method.
AuthProvider provider = manager.connect(paramsMap);
// get profile
Profile p = provider.getUserProfile();
// you can obtain profile information
System.out.println(p.getFirstName());
// OR also obtain list of contacts
List<Contact> contactsList = provider.getContactList();
The comment at line 3-4 say that we should pass the request parameter map to manager.connect()
. I tried:
manager.connect(request.getParameterMap());
But it gives
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String
Should I create my own parameter map instead of passing map returned by request.getParameterMap()
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答我自己的问题:
socialauth 源有一个包含以下代码的示例:
它修复了 classcastexception
Answering my own question:
The socialauth source have a sample with following code:
Which fixes the classcastexception