Craig, could please give an advice with 'canvas' app implementation?
The question what is the best approach to update 'Connection' record using data from 'signed_request' parameter?
Say I can get 'access_token' from 'signed_request' by controller code, but I can't directly update 'oauth_token' + 'expires'
Code:
@RequestMapping(value = "/canvas", method = RequestMethod.POST)
NativeWebRequest request,
Model model) {
......
Map<String, ?> decoded = decoder.decodeSignedRequest(signedRequest);
String providerUserId = (String)decoded.get("user_id");
String oauthTokenValue = (String)decoded.get("oauth_token");
Integer expiresTimeValue = (Integer)decoded.get("expires");
// check is it first access attempt or rather consequent access ?
if (providerUserId == null &&
oauthTokenValue == null
&& expiresTimeValue == null) {
// OAuth dance flow......
/// Connection<?> connection WILL BE STORED HERE AT FIRST TIME
} else {
/// Good, that is second access, let's create Internal User...
ConnectionKey key = new ConnectionKey("facebook", providerUserId);
org.springframework.social.connect.ConnectionRepository connectionRepository =
usersConnectionRepository.createConnectionRepository(providerUserId);
Connection<?> connection = connectionRepository.getConnection(key);
// it would be good to update connection :
connectionRepository.updateConnection(connection);
// but there is no setter on Connection<?> connection !!! OPS.....
connection.setOauthToken(oauthTokenValue);
connection.setExpiresTime(expiresTimeValue);
// That's good I can call to FB API !!!
facebook = facebookServiceProvider.getApi(oauthTokenValue);
.........
Should I'd better use custom 'work around' code ?