我尝试使用Facebook或其他社交网络实现Spring社交。
我做错了,但我不知道它是什么。
当我在日志中向facebook发出请求时,我看到200 (OK)
,但我无法获取已登录的用户。
我看到的日志:
首先我看到facebook返回用户:
2014-11-19T14:18:48.156+0100|Info: http-outgoing-1 << "{"id":"***","first_name":"***","gender":"male","last_name":"***","link":"https:\/\/www.facebook.com\/app_scoped_user_id\/***\/","locale":"es_ES","name":"***","timezone":2,"updated_time":"2014-03-20T21:50:00+0000","verified":true}"
但在请求之后我看到了:
2014-11-19T14:18:48.164+0100|Info: GET request for "https://graph.facebook.com/me" resulted in 200 (OK)
2014-11-19T14:18:48.165+0100|Info: Reading [class org.springframework.social.facebook.api.FacebookProfile] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@3ee8e5cb]
2014-11-19T14:18:48.165+0100|Info: Connection [id: 1][route: {s}->https://graph.facebook.com:443] can be kept alive indefinitely
2014-11-19T14:18:48.165+0100|Info: Connection released: [id: 1][route: {s}->https://graph.facebook.com:443][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
2014-11-19T14:18:48.198+0100|Info: Authentication attempt using org.springframework.social.security.SocialAuthenticationProvider
2014-11-19T14:18:48.220+0100|Info: Executing prepared SQL query
2014-11-19T14:18:48.223+0100|Info: Executing prepared SQL statement [select userId from UserConnection where providerId = ? and providerUserId = ?]
2014-11-19T14:18:48.243+0100|Info: Fetching JDBC Connection from DataSource
2014-11-19T14:18:48.288+0100|Info: Returning JDBC Connection to DataSource
2014-11-19T14:18:48.298+0100|Info: Authentication request failed: org.springframework.social.security.SocialAuthenticationRedirectException:
2014-11-19T14:18:48.299+0100|Info: Updated SecurityContextHolder to contain null Authentication
2014-11-19T14:18:48.299+0100|Info: Delegating to authentication failure handler org.springframework.social.security.SocialAuthenticationFailureHandler@20cc9603
2014-11-19T14:18:48.299+0100|Info: SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
2014-11-19T14:18:48.300+0100|Info: SecurityContextHolder now cleared, as request processing completed
当我在表格中查看我的数据库&#34; UserConnection&#34;我没有看到用户。
此外,当我试图让主要用户始终是匿名的时候。
我不知道错误在哪里或我需要修改或创建的类。我可以把所有的代码。
提前致谢。 STEL。
答案 0 :(得分:0)
您使用的是SpringSocialConfigurer吗?您只是简单地调用&#34; / auth / {provider}&#34;?
我的猜测是你有以下问题:
您已成功通过脸书登录
你可以做一些事情来测试
参见这个好的教程