I'm quite new to sprig / spring-social. I'm trying to execute a request to Facebook API from my spring boot (v1.4) application to exchange the auth code (which I get with my front-end app) for an accessToken. Here is the way I do it
FacebookConnectionFactory facebookConnectionFactory = new FacebookConnectionFactory(fbAppId, fbAppSecret);
AccessGrant accessGrant = facebookConnectionFactory.getOAuthOperations()
.exchangeForAccess(authCode, redirectUri, null);
As a result I get the AccessGrant with an accessToken equals null. Trying to debug the code-for-token exchange flow I can see that the correct authToken is actually received in the FacebookOAuth2Template::postForAccessGrant(), but for some reason its converted to MultiValueMap<String, String>, i.e.:
protected AccessGrant postForAccessGrant(String accessTokenUrl, MultiValueMap<String, String> parameters) {
MultiValueMap<String, String> response = getRestTemplate().postForObject(accessTokenUrl, parameters, MultiValueMap.class);
String expires = response.getFirst("expires");
return new AccessGrant(response.getFirst("access_token"), null, null, expires != null ? Long.valueOf(expires) : null);
}
My response MultiValueMap thus contains a single entry with a key that is facebook authToken response. Apparently, all the subsequent response.getFirst() calls return nothing
I'm pretty much sure I'm missing something obvious here but still I cannot get why the authToken response gets converted to MutliValueMap the way it does
Seems like an older version of the spring-social-facebook dependency (1.1.0) was pulled into the project and used in communication. Upgrade to the 2.x version solved the issue