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.

I am creating a private portal (a private website where I automatically auto-log to all my favorite website). Every website is loaded in an iframe.

I am looking for a way to autologin to ubuntuone. I tried to post a automatically completed form, but ubuntuone uses a unique key for each authentication. I can not use jquery to sumbit the form from outside of the iframe because it's not the same domain.

Maybe in PHP ? This post talk about Ubuntu one auth and PHP but I don't know how PHP could interact with the API. May you have some example ?

Thanks for ideas and your help.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The easy way to do this is simply to sign in to Ubuntu One in your browser, and then put https://one.ubuntu.com in the iframe; you'll stay signed in for a while at least (and you're signed out occasionally for security).

The hard way, if you want to be sure that you're always signed in, is to take the URL https://one.ubuntu.com/api/1.0/from_oauth/?next=/ and sign it with a valid Ubuntu One OAuth token. You can retrieve a token using the Python library in https://launchpad.net/ubuntuone-couch or manually from your Ubuntu keyring. Once you've signed the URL with that OAuth token, serialise the OAuth signature into the URL (so you'll get a URL which looks like

and then open it in your web browser. That URL will take you to Ubuntu One, in the browser, signed in as you.

You may find the following page useful, which does the signing in JavaScript: edit this page to include your token details, and then you can just open this page in the browser and bookmark it, or link to it in an iframe with a file:// URL, and it should work. It also requires oauth.js and sha1.js from http://oauth.googlecode.com/svn/code/javascript/.

<!doctype html>
<html><head><title>Log in to Ubuntu One without password</title>
<script src="sha1.js"></script><script src="oauth.js"></script>
</head><body>
<script>
var url = "https://one.ubuntu.com/api/1.0/from_oauth/"
var accessor = {
  token: "TTTTTTTT",
  tokenSecret: "SSSSSSSSS",
  consumerKey : "CCCCCCCC",
  consumerSecret: "ssssssssss"
};
var message = {
  action: url,
  method: "GET",
  parameters: {next: "/"}
};
OAuth.completeRequest(message, accessor);
OAuth.SignatureMethod.sign(message, accessor);
url = url + '?' + OAuth.formEncode(message.parameters);
location.href = url;
</script>
</body>
</html>
share|improve this answer
    
Thank you very much for all this informations. I will try to get the token with PHP (helped by the post whom I gave the url in my first post). I will write back when it will be done. –  Simon Dubois Jul 25 '11 at 16:03
    
Ah, be careful. The stuff in the linked post is about getting a new token; it's not about using an existing one. If you use that approach, please store the token once you've retrieved it; don't get a new one every go! –  sil Jul 25 '11 at 16:29
    
I have follow all the step of your answer to the linked post and I manage to get a new token. But I don't have oauth_signature. Where can I get it ? –  Simon Dubois Jul 26 '11 at 10:01
    
You'll need to use an OAuth library to calculate the signature. There are libraries for Python, PHP, and so on; choose whichever you like best. For example, you could use something like the code in the linked post to OAuth sign the URL in PHP... so your iframe would point to localhost/u1login.php, and then that page would take the token and the one.ubuntu.com/api/1.0/from_oauth/?next= URL, sign the URL with the token, and do a PHP redirect to the right place. You could also do this in JavaScript if you preferred. –  sil Jul 26 '11 at 11:35
    
I've added a pure JavaScript example to do all the OAuth stuff; all you need do is add your own token to it. –  sil Jul 26 '11 at 14:26

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.