2012-12-05 1 views
3

Google 계정의 '도메인 관리자'이며 다음을 원합니다. 내 도메인의 모든 사용자와 '각 사용자'에 대해 사용자가 모든 사람의 파일을 읽음.. 나는 각 사용자를 얻을 수 있지만, 지금은 각 사용자 문서를 얻는 방법을 이해하지 못합니다.Google 드라이브 API를 사용하는 모든 사용자의 모든 파일을 가져 오는 방법

#!/usr/bin/python 
import gdata.docs 
import gdata.docs.service 
from gdata.apps import client 

userNameAtGmailCom = '[email protected]' 
password   = 'mypassword' 
personToShareWith = "[email protected]" 
domain    = 'someplace.com' 

def login(userNameAtGmailCom, password, personToShareWith, domain): 
    client = gdata.apps.client.AppsClient(domain=domain) 
    client.ssl = True 
    client.ClientLogin(email=userNameAtGmailCom, password=password, source='apps') 
    all_users = client.RetrieveAllUsers() 
    for user in all_users.entry: 
       user_name = user.login.user_name 
       print user_name 
       password = user.login.password 
       print password 
       clientDocs = gdata.docs.service.DocsService() 
#password always returns 'none' 
#therefore I've commented out the 'bad authentication' 
#that would happen if the lines below ran 
       #clientDocs.ClientLogin(user_name, password) 
       #documents_feed = clientDocs.GetDocumentListFeed() 
       #for document_entry in documents_feed.entry: 
       #print document_entry.title.text 
       #scope = gdata.docs.Scope(value=personToShareWith, type='user') 
       #role = gdata.docs.Role(value='reader') 
       #acl_entry = gdata.docs.DocumentListAclEntry(scope=scope, role=role) 
       #created_acl_entry = client.Post(acl_entry, document_entry.GetAclLink().href, converter=gdata.docs.DocumentListAclEntryFromString) 

login(userNameAtGmailCom, password, personToShareWith, domain) 
+0

을 https://developers.google.com/gdata/docs/auth/clientlogin – jjamesjohnson

답변

3

당신은 Google 드라이브 API를 사용하여 권한의 Google Apps 도메인 전체에 위임 수행하는 서비스 계정을 사용해야합니다 : 이미 AUTH_TOKEN 설립 및 그것을 가지고 한 필요 보인다

https://developers.google.com/drive/delegation

+0

감사합니다. Claudio, 나는 또한 clientDocs를 시도했습니다. clientDocs = gdata.docs.service.DocsService() (및 내 스크립트를 편집했습니다. 위 보여 주려면 위)하지만, '비밀번호'는 eac에서 반환됩니다. h user는 항상 'none'이므로 clientLogin은 잘못된 인증을 반환합니다. 아이디어? – user1709076

+0

보안상의 이유로 API를 사용하여 사용자의 암호를 검색 할 수 없습니다. 일반적으로 다른 사용자에게 자격 증명을 요청해서는 안되며, 내 응답의 링크에 문서화해야합니다. –

+0

안녕하세요 클라우디오, 귀하의 회신에 감사드립니다. 파이썬이 "SignedJwtAssertionCredentials"를 가져올 수 없기 때문에 드라이브 위임 방식을 포기했습니다. 대신 Java로 포팅하여 어떻게 진행되는지 살펴 보겠습니다. – user1709076

관련 문제