我试图在我的应用程序中使用Google应用程序引擎获取spring security oauth2安装程序。一切似乎本地正常工作,但是当我部署到应用程序引擎的事情开始打破。在我通过谷歌身份验证后,将其转发给白标错误页面。在控制台中我看到这样的错误:在Google App Engine上启用Oauth2sso
http://my-application.appspot.com/login?state=t…m&session_state=8b67f5df659a8324430803973b9e1726e39fd454..1ae3&prompt=none
401 (Unauthorized)
设置我的身份验证与此application.yml文件:
security:
oauth2:
client:
clientId: client-key
clientSecret: secret-key
accessTokenUri: https://www.googleapis.com/oauth2/v4/token
userAuthorizationUri: https://accounts.google.com/o/oauth2/v2/auth
clientAuthenticationScheme: form
scope:
- openid
- email
- profile
- https://www.googleapis.com/auth/cloud-platform
resource:
userInfoUri: https://www.googleapis.com/oauth2/v3/userinfo
preferTokenInfo: true
我的安全配置看起来somethign像这样:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.and()
.authorizeRequests()
.antMatchers("/static/**").permitAll()
.antMatchers("/**").hasAuthority("ROLE_ADMIN")
.anyRequest().authenticated()
.and()
.exceptionHandling()
.accessDeniedPage("/403");
}
我有在Google凭据页面上配置了Oauth ID,以允许授权的javascript来源为:
http://my-application.appspot.com
https://my-application.appspot.com
http://localhost:8080
与经授权的重定向URI来:
http://my-application.appspot.com/login
https://my-application.appspot.com/login
http://localhost:8080/login
任何想法,为什么我可能会得到授权错误,当我部署到GAE?
感谢,
克雷格
你确定你正在尝试与有 “ROLE_ADMIN” 权威认证用户? –
积极。我试图剥离出来,只留下所有页面上的oauth身份验证,它仍然给出相同的错误。 – craigtb
如果可能,您可以在GitHub上共享一个最小的,可重现的示例项目吗? –