2016-07-23 54 views
0

我正在尝试构建基本的Spring Boot应用程序,该应用程序允许将用户身份验证的工作委托给外部OAuth2提供程序(如Facebook)。使用Spring Boot进行OAuth2身份验证后无法正确重定向

我有两个主要问题:

  1. 一旦认证过程完成后,我得到:

GET request for " https://graph.facebook.com/me " resulted in 200 (OK)

我还可以得到以下几点:

Reading [interface java.util.Map] as "application/json" using [org.springfr[email protected]2a7ce52b] Delegating to org.springframework.security.w[email protected]4f061f45 SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.

这就好像分析和存储返回的凭证有问题。

  • 有时我得到一个401错误:
  • Authentication request failed: org.springframework.security.authentication.BadCredentialsException: Could not obtain access token

    它是某种碰运气的,我无法追踪下来的问题。它也发生在使用Google OAuth2时。

    我基本上使用的@ 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 
    

    任何帮助是非常赞赏:)

    回答

    0

    最后我设法解决这个问题, spring-boot-starter-tomcat maven dependency已被标记为<scope>provided</scope>,因此干扰了正确初始化嵌入式tomcat中的spring上下文对象的能力。

    相关问题