Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

For what I promise are un-nefarious reasons, I'd like to programmatically fetch the Ubuntu One account details for the current user of an application (eg name, email, free space). Is there way to achieve this?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Yes. Ubuntu One provides an OAuth-secured Web API for account details; the OAth credentials of the local user are accessible via the freedesktop.org secrets keyring service. Of course, you can't read these credentials willy-nilly, as the user needs to password-unlock them.

Fortunately, you do not need to navigate the maze of technologies on your own (as I did), but can instead can use a handy tool Ubuntu One provides:

u1oauthrequest https://one.ubuntu.com/api/account/

If the current user doesn't have a U1 account, this will raise a CredentialsNotFound error. Otherwise it will return a server response in the form of a JSON string. Check the 'status' value to make sure the authentication went through ('200' indicates success). On success, the JSON will have the values:

username, openid, last_name, features, couchdb_root, nickname, id, subscription, first_name, couchdb, total_storage, current_plan, email, detailed_plans

Wield your API powers responsibly.

share|improve this answer

Your Answer

 
discard

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.