Rasool Ghafari
Rasool Ghafari

Reputation: 4278

facebook throws "An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response" when use oauth2

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

Upvotes: 1

Views: 817

Answers (2)

Eteka Christopher
Eteka Christopher

Reputation: 133

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)

Upvotes: 0

Peter Shneider
Peter Shneider

Reputation: 133

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

Upvotes: 3

Related Questions