Ubuntu One クラウドへの OAuth リクエストは空の応答を返しますか?

Ubuntu One クラウドへの OAuth リクエストは空の応答を返しますか?

現在、Ubuntu Bada アプリを開発しています。API 経由でトークンを取得できますが、API の他の部分を要求しようとすると、空のブラウザ ウィンドウが表示されるか、アプリの http リスナーでイベントが発生しません。

私のリクエスト URL は次のようになります:

https://one.ubuntu.com/api/file_storage/v1?oauth_consumer_key=abc&oauth_token=def&oauth_nonce=xdobeqcqyfjnzjsh&oauth_timestamp=1328656660424&oauth_signature_method=PLAINTEXT&oauth_version=1.0&oauth_signature=uvw%26xyz

さまざまなサイトでパラメータを見つけましたが、それが有効かどうかわかりません。

ご協力いただきありがとうございます!!

答え1

トークンの詳細を使用する必要がありますリクエストに署名するOAuth プロトコルを使用します。

以下は、Ubuntu で実行される Python スクリプトの例です。このスクリプトは URL に署名し、その URL を出力します。その後、その URL を要求すると、動作するはずです。

それでも問題が解決しない場合はお知らせください。(注: API はデータを content-type として返すためapplication/json、モバイル ブラウザーでは読み込まれない可能性があります。)

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.
  try:
      credentials = get_oauth_credentials()
  except CredentialsNotFound:
      print "COULDN'T GET CREDENTIALS"
      sys.exit()
  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(
      http_url=url,
      http_method="GET",
      oauth_consumer=consumer,
      token=token,
      parameters=parameters)
  oauth_request.sign_request(signature_method, consumer, token)
  print oauth_request.to_url()

関連情報