首页 > 解决方案 > facebook 在使用 oauth2 时抛出“尝试检索 OAuth 2.0 访问令牌响应时发生错误”

问题描述

我想在带有 Spring Boot 的 mu Web 应用程序中使用 oauth2 和 facebook,这是为此目的的配置:

spring:
  security:
    oauth2:
      client:
        registration:
          google:
            clientId: clientIdValue
            clientSecret: clientSecretValue
            redirectUri: "https://www.example.com/oauth2/callback/{registrationId}"
            scope:
              - email
              - profile
          facebook:
            clientId: clientIdValue
            clientSecret: clientSecretValue
            redirectUri: "https://www.example.com/oauth2/callback/{registrationId}"
            scope:
              - email
              - public_profile
        provider:
          facebook:
            authorizationUri: https://www.facebook.com/v3.0/dialog/oauth
            tokenUri: https://graph.facebook.com/v3.0/oauth/access_token
            userInfoUri: https://graph.facebook.com/v3.0/me?fields=id,first_name,middle_name,last_name,name,email,verified,is_verified,picture.width(250).height(250)
server:
  port: 443
  ssl:
    key-store-type: PKCS12
    key-store: classpath:keystore/sslkeystore.p12
    key-store-password: passwordValue
    key-alias: tomcat
    enabled-protocols:
      - TLSv1
      - TLSv1.1
      - TLSv1.2

Google 身份验证工作正常,但在 facebook 中,我在重定向到我的网站后收到此错误:

An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: I/O error on POST request for \"https://graph.facebook.com/v3.0/oauth/access_token\": Remote host closed connection during handshake; nested exception is javax.net.ssl.SSLHandshakeException: Remote host closed connection during

标签: facebookspring-bootfacebook-graph-apioauth-2.0spring-security-oauth2

解决方案


尝试删除这个:

provider:
  facebook:
    authorizationUri: https://www.facebook.com/v3.0/dialog/oauth
    tokenUri: https://graph.facebook.com/v3.0/oauth/access_token
    userInfoUri: https://graph.facebook.com/v3.0/me?fields=id,first_name,middle_name,last_name,name,email,verified,is_verified,picture.width(250).height(250)

这对我有帮助


推荐阅读