Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing a java app in eclipse that backups data to several consumer-cloud-services encrypted and redundant.

So far, I successfully implemented the authentication process, as it is described in the documentation.

At this point, I do not know how to proceed. The next step would be implementing the auth with the stored AccessToken and afterwars implementing upload/download/listing functionality through the REST API.

  1. I think I have to store the String oauth.getSerialized(). How do I authenticate with this String afterwards? This does not work e.g.:

    AuthenticateResponse oauth = api.authenticate(serialized);
    api.setAuthorizer(new OAuthAuthorizer(oauth));
  2. Can someone tell me please, how I can use the REST API with java? There is no explanation or link in the developers area as far as I saw.

And btw, I wasted at least one hour trying to fix errors, because some needed libraries are listet after the example code. :/

share|improve this question

I managed to solve this.

As you mention you are able to store the auth tokens. So following is the way forward:

Objective: Create the U1FileAPI object

public U1FileAPI(String appPackageName, String appVersion,
    HttpClient httpClient, Authorizer authorizer)

Constructor accepts :

  1. appPackageName >This is same as package name you have given @ the time of authentication creation
  2. appVersion >This is same as appVersion name you have given @ the time of authentication creation
  3. httpClient > create a new one HttpClient httpClient = new DefaultHttpClient();
  4. authorizer > For this you require little effort:

    ObjectInputStream input = new ObjectInputStream(
        new FileInputStream("/file/where/you/save/auth/tokens"));

Create the OAuthAuthorizer object:

OAuthAuthorizer aOuth = OAuthAuthorizer.getWithTokens(
    input.readObject().toString(), new HmacSha1MessageSigner());

Now you are good to go for U1FileAPI creation:

U1FileAPI   uOneFs = new U1FileAPI(package_api, version, httpClient, aOuth);

Use the expose methods of uOneFs to solve your actual backup requirements.

While browsing found Cross reference for Ubuntu One, hope it will also help you to understand this better:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.