[英]Unable to properly redirect after OAuth2 authentication using Spring Boot
I'm trying to build a basic Spring Boot app that will allow me delegate the work of authenticating users to an external OAuth2 provider such as Facebook. 我正在尝试构建一个基本的Spring Boot应用程序,该应用程序将允许我将对用户进行身份验证的工作委派给外部OAuth2提供程序,例如Facebook。
I've got two main issues: 我有两个主要问题:
GET request for " https://graph.facebook.com/me " resulted in 200 (OK)
GET请求“ https://graph.facebook.com/me ”,结果为200(确定)
I also get the following: 我也得到以下信息:
Reading [interface java.util.Map] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@2a7ce52b] Delegating to org.springframework.security.web.authentication.session.ChangeSessionIdAuthenticationStrategy@4f061f45 SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
使用[org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@2a7ce52b]将[interface java.util.Map]读取为“ application / json”,委托给org.springframework.security.web.authentication.session.ChangeSessionIdAuthenticationStrategy@4f061f45为空或内容为匿名-上下文将不会存储在HttpSession中。
It is as if something is wrong with parsing and storing the returned credentials. 好像解析和存储返回的凭据有问题。
Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Could not obtain access token
身份验证请求失败:org.springframework.security.authentication.BadCredentialsException:无法获取访问令牌
It is a some sort of hit and miss, and I could not trace down the problem. 这是一种偶然,我无法找到问题所在。 It also happened when using Google OAuth2 instead.
改为使用Google OAuth2时也会发生。
I Basically used the @EnableOAuth2Sso annotation, and configured the credentials using the application.yml file: 我基本上使用@ EnableOAuth2Sso批注,并使用application.yml文件配置凭据:
security:
oauth2:
client:
clientId: 123
clientSecret: bla
accessTokenUri: https://graph.facebook.com/oauth/access_token
userAuthorizationUri: https://www.facebook.com/dialog/oauth
tokenName: oauth_token
authenticationScheme: query
clientAuthenticationScheme: form
resource:
userInfoUri: https://graph.facebook.com/me
preferTokenInfo: false
Any help is much appreciated :) 任何帮助深表感谢 :)
最终,我设法解决了这一问题,将spring-boot-starter-tomcat
maven依赖项标记为<scope>provided</scope>
,从而干扰了在嵌入式tomcat中正确初始化spring上下文对象的能力。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.