Results 1 to 5 of 5

Thread: Spring Social Web - Activity object without content when Accessing with OAuth2

Threaded View

  1. #1
    Join Date
    Jan 2012
    Posts
    6

    Question Spring Social Web - Activity object without content when Accessing with OAuth2

    Hi everyone.

    I'm trying to use spring-social-google to search activities in google+, but when i get the activity objects they came with the Content property set to null. Is this a permission problem?

    I use OAuth2 to get the permissions. The code is like this:

    Code:
    OAuth2Operations oauthOperations = googleConnectionFactory.getOAuthOperations();
        OAuth2Parameters params = new OAuth2Parameters();
        params.setRedirectUri(applicationUrl + GOOGLE_REDIRECT_URI);
        params.setScope("https://www.googleapis.com/auth/plus.me https://www.google.com/m8/feeds/ https://www.googleapis.com/auth/userinfo.email  https://www.googleapis.com/auth/userinfo.profile");
        params.set("access_type", "offline");
        params.set("approval_prompt","force");
        
        String authorizeUrl = oauthOperations.buildAuthorizeUrl( GrantType.AUTHORIZATION_CODE, params );
    I get the Access token and Refresh token with no problem, then i made the search with:

    Code:
    		List<Publication> activities = new ArrayList<Publication>();
    		ActivityQueryBuilder searchResult = google.activityOperations().activityQuery();
    		searchResult.searchFor(query);
    		ActivitiesPage page = searchResult.getPage();
    		List<? extends Activity> activityList = page.getItems();
    		activities.addAll( (List<Publication>) CollectionUtils.collect( activityList, new ActivityToPublicationTransformer() ) );
    The transformer contains this transform method:

    Code:
    public Object transform(Object input) {
    		Publication publication = null;
    		if (input instanceof Activity){
    			User user = new User();
    			Activity activity = (Activity) input;
    			publication = new Publication();
    			publication.setPublicationId(activity.getId());
    			publication.setType( PublicationType.ACTIVITY );
    			publication.setSocialNetwork( SocialNetwork.GOOGLE );
    			user.setName(activity.getActor().getDisplayName());
    			user.setUserId(activity.getActor().getId());
    			publication.setUser(user);
    			publication.setMessage(activity.getContent());
    			publication.setCreatedTime(activity.getPublished());
    			publication.setShares(activity.getResharers());
    			publication.setComments(activity.getReplies());
    			publication.setAttentions( new ArrayList<Attention>() );
    		}
    		return publication;
    	}
    When I debug the application, the instrucction "activity.getContent()" in the transformer returns me null, but activity.getPublished() or activity.getId() works fine.

    Any hint about what am i doing wrong?

    Is there any page with the JavaDoc of spring-social-google? I searched it but i didn't find it

    P.D. Sorry mi bad english, it's not my natural language.
    P.D.2 I just realized I wrote wrong the title, it should begin with "Spring Social Google" not "Spring Social Web", could an admin change the title?
    Last edited by luisfmp; Sep 27th, 2012 at 05:17 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •