如何访问某个谷歌用户的驱动器 [英] how to access drive as certain google user
问题描述
我正在使用appengine(python)并尝试管理某个用户的共享谷歌驱动器目录。即使我以不同的用户身份登录,我的程序是否也可以访问驱动器,而无需访问授权页面。说我登录123,但我想一直访问abc的谷歌驱动器。
I am using appengine( python) and trying to manage a shared google drive directory for certain user. Can my program always access the drive without to go to authorize page, even when I am login as different user. Say I login 123 but I want to access abc's google drive all the time.
推荐答案
当用户添加一个应用程序引擎项目服务帐户作为一个共享,您可以随时访问它,而无需使用OAuth2跳舞。
When the user adds a app engine project service account as a share, you can always access it, without the OAuth2 dance.
您的应用引擎项目服务帐户如下所示:example@appspot.gserviceaccount.com
您可以在此处找到以下信息: https://developers.google.com/drive/service-账户#google_app_engine_project_service_accounts
Your app engine project service account looks like : example@appspot.gserviceaccount.com You can find information here : https://developers.google.com/drive/service-accounts#google_app_engine_project_service_accounts
def _init_service_account(self):
if os.environ['SERVER_SOFTWARE'].startswith('Development') :
logging.warning('Service account not used in development')
return None
else :
SCOPE = 'https://www.googleapis.com/auth/drive'
API_KEY = '.....' # GAE
credentials = AppAssertionCredentials(scope=SCOPE)
logging.info('service account : ' + app_identity.get_service_account_name())
http = credentials.authorize(httplib2.Http())
return build('drive', 'v2', http=http, developerKey=API_KEY)
这篇关于如何访问某个谷歌用户的驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!