2012-04-12 15 views
1

私はこれを完全に読んでいます:https://developers.google.com/google-apps/documents-list/#using_google_apps_administrative_access_to_impersonate_other_domain_users 私はこれを拒否しました。Googleドキュメント:管理アクセス/偽装(禁止403)を使用してユーザーのドキュメントをPythonでエクスポート/ダウンロードできません

  1. 承認を::(私のドメインキーを使用して)

  2. のOAuthトークン
  3. は、文書のフィードを取得

    • ClientLoginのこれまでのところ、私がすることができた

      ドメイン内のすべてのユーザー用(#1のいずれかの方法で許可)
      フィードの「エントリ」を使用して、ドキュメントをエクスポート/ダウンロードし、管理者と共有されていないドキュメントの他のユーザーには常に禁止されます。私が使用していますフィードクエリは次のようである:https://docs.google.com/feeds/[email protected]/private/full/?v=3 は(?私はとせずに試してみましたが、V = 3)

私も(私もxoauth_requestorとして記事で見てきた)xoauth_requestor_idを追加しようとしています、両方のURIに、クライアントのプロパティとして:client.xoauth_requestor_id = ...

コードの断片:

クライアントログイン(管理者の資格情報を使用して):

client.http_client.debug = cfg.get('HTTPDEBUG') 
client.ClientLogin(cfg.get('ADMINUSER'), cfg.get('ADMINPASS'), 'HOSTED') 

のOAuth:

client.http_client.debug = cfg.get('HTTPDEBUG') 
client.SetOAuthInputParameters(gdata.auth.OAuthSignatureMethod.HMAC_SHA1, cfg.get('DOMAIN'), cfg.get('APPS.SECRET')) 
oatip = gdata.auth.OAuthInputParams(gdata.auth.OAuthSignatureMethod.HMAC_SHA1, cfg.get('DOMAIN'), cfg.get('APPS.SECRET')) 
oat = gdata.auth.OAuthToken(scopes = cfg.get('APPS.%s.SCOPES' % section), oauth_input_params = oatip) 
oat.set_token_string(cfg.get('APPS.%s.TOKEN' % section)) 
client.current_token = oat 

フィード一度取得されます。

# pathname eg whatever.doc 
client.Export(entry, pathname) 
# have also tried 
client.Export(entry, pathname, extra_params = { 'v': 3 }) 
# and tried 
client.Export(entry, pathname, extra_params = { 'v': 3, 'xoauth_requestor_id': '[email protected]' }) 

任意の提案、またはポインタは、私がここで行方不明です何のよう? ありがとう

+0

この質問が回答されている場合、あなたはそれが答えマークすることができますか?また、あなたのコメントに記載されている他の401/403を再現するためのステップで新しい質問を投稿してください。 –

答えて

1

あなたは正しく実装されています。上記のあなたの例では、あなたが持っていた:

client.Export(entry, pathname, extra_params = { 'v': 3, 'xoauth_requestor_id': '[email protected]' }) 

xoauth_requestor_idはあなたが偽装しているユーザーに設定する必要があります。また、必要なのは、2-Legged OAuth 1.0aをxoauth_requestor_idをトークンまたはクライアントのいずれかに設定して使用することです。ここで

import gdata.docs.client 
import gdata.gauth 

import tempfile 


# Replace with values from your Google Apps domain admin console 
CONSUMER_KEY = '' 
CONSUMER_SECRET = '' 

# Set this to the user you're impersonating, NOT the admin user 
username = '[email protected]' 
destination = tempfile.mkstemp() 

token = gdata.gauth.TwoLeggedOAuthHmacToken(
    consumer_key, consumer_secret, username) 
# Setting xoauth_requestor_id in the DocsClient constructor is not required 
# because we set it in the token above, but I'm showing it here in case your 
# token is constructed via some other mechanism and you need another way to 
# set xoauth_requestor_id. 
client = gdata.docs.client.DocsClient(
    auth_token=token, xoauth_requestor_id=username) 
# Replace this with the resource your application needs 
resource = client.GetAllResources()[0] 
client.DownloadResource(resource, path) 
print 'Downloaded %s to %s' % (resource.title.text, destination) 

はTwoLeggedOAuthHmacTokenクラスのソースコード内の参照です:

  1. http://code.google.com/p/gdata-python-client/source/browse/src/gdata/gauth.py#1062

そして、ここではxoauth_requestor_idコンストラクタのパラメータを提供し、ソースコード内の参照(読み取りますこれらは順番に):

  1. http://code.google.com/p/gdata-python-client/source/browse/src/atom/client.py#42
  2. http://code.google.com/p/gdata-python-client/source/browse/src/atom/client.py#179
  3. http://code.google.com/p/gdata-python-client/source/browse/src/gdata/client.py#136
+0

ありがとうございます。今より多くの成功。 401または403のいずれかのファイルが残っていますが、別の理由が考えられます –

関連する問題