0

I have a problem. I'm building a service, that can use a oauth-service, to get some userinformation. I would like to persist the OAuthService, on the user, because I need to get the data, until the accessToken expires(That differs from each providers)..

I use the play2-morphia-plugin for data persistance, and Scribe for OAuth..

Here's my user class:

package models;

import leodagdag.play2morphia.Model;
import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Id;
import org.bson.types.ObjectId;
import org.scribe.oauth.OAuthService;


@Entity
public class User extends Model{
    @Id
    private ObjectId id;
    private List<OAuthService> services;

    //Getters and setters...
}

I can save the object. No problem, but when i try to load it, I get an error because it doesn't have an default empty constructor.

I can put the code on github, if you would like?

1 Answers1

0

I figured it out finally :)

I just made a class, for storing the data. The Class org.scribe.oauth.OAuthService, doesn't contain any data, so there is no reason for Serialization.

public class ServiceConnection {

    private Date accessFrom;
    private Class<? extends Api> apiClass;
    private SignatureType signatureType;
    private String apiKey;
    private String secretKey;
    private String callback;
    @Serialized
    private Token requestToken;
    @Serialized
    private Token accessToken;

    // Getter and setters..

}