SocialAuthentication auth = connectionToAuth(connection);
userService.connect(userId, auth);
}
public static SocialAuthentication connectionToAuth(Connection<?> connection) {
SocialAuthentication auth = new SocialAuthentication();
ConnectionData data = connection.createData();
auth.setProviderId(data.getProviderId());
auth.setToken(data.getAccessToken());
auth.setRefreshToken(data.getRefreshToken());
auth.setSecret(data.getSecret());
auth.setProviderUserId(data.getProviderUserId());
return auth;
}