'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
Solution 1:[1]
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
Solution 2:[2]
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)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Peter Shneider |
| Solution 2 | Eteka Christopher |
