1

I want to use oauth2 with facebook in mu web application with spring boot and this is configuration for this purpose:

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 authentication works fine, but in the facebook i get this error after redirect to my site:

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
Rasool Ghafari
  • 4,128
  • 7
  • 44
  • 71
  • 1
    Did you try to research the error message …? https://stackoverflow.com/questions/21245796/javax-net-ssl-sslhandshakeexception-remote-host-closed-connection-during-handsh – CBroe Jun 09 '20 at 14:05
  • @CBroe, Yes, i do that, but didn't solve the problem. – Rasool Ghafari Jun 10 '20 at 06:42

2 Answers2

3

Try to remove this:

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)

It's help to me

Peter Shneider
  • 123
  • 1
  • 10
0

Replace the value for userInfoUri with the following: https://graph.facebook.com/v3.0/me?fields=id,email,first_name,middle_name,last_name,name,verified,picture.width(250).height(250)