I am currently developing a ubuntuone Bada app. I can get the tokens via the api, but if I try to request any other part of the api I just get an empty browser window or no event fired in the http listener of the app.

My request url looks like this:


I found the parameters on various sites and I am not sure if they are valid.

Thanks for your help!!


You need to use the token details you have to sign the request with the OAuth protocol.

Here's an example Python script, to be run on Ubuntu, which will sign a URL and then print out that URL; if you then request that URL, it should work.

Let me know if this is still problematic. (Note: the API returns data as content-type application/json, so this may not be loaded in a mobile browser.)

import oauth, urlparse, sys
from ubuntuone.couch.auth import *
if __name__ == "__main__":
  # If you already have token details, then use them here; you'll need
  # access_token, token_secret, consumer_key, and consumer_secret. This
  # script fetches them from a running Ubuntu instead.
      credentials = get_oauth_credentials()
  except CredentialsNotFound:
  access_token = credentials['token']
  token_secret = credentials['token_secret']
  consumer_key = credentials['consumer_key']
  consumer_secret = credentials['consumer_secret']

  # Now we have token details; let's use them to sign a request.

  token = get_oauth_token(access_token, token_secret)
  consumer = oauth.OAuthConsumer(consumer_key, consumer_secret)

  url = "https://one.ubuntu.com/api/file_storage/v1"
  request_body = ""
  signature_method = HMAC_SHA1

  parameters = {}
  query = urlparse.urlparse(url)[4]
  for key, value in urlparse.parse_qs(query).items():
      parameters[key] = value[0]

  request_len = len(request_body) if request_body else 0
  timeout = 10 * (request_len / 1024 / 1024 + 1)  # 10 seconds per megabyte

  oauth_request = oauth.OAuthRequest.from_consumer_and_token(
  oauth_request.sign_request(signature_method, consumer, token)
  print oauth_request.to_url()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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