appengine(python)を使用していて、特定のユーザーの共有googleドライブディレクトリを管理しようとしています。別のユーザーとしてログインしている場合でも、プログラムは認証ページに移動せずに常にドライブにアクセスできますか?123にログインしたが、abcのGoogleドライブに常にアクセスしたいとします。
2 に答える
これは、Google Apps ユーザー向けのドメイン全体の委任 ( https://developers.google.com/drive/delegation ) を通じて行うことができますが、ドメイン管理者は承認のためにアプリを追加する必要があります。
手動で設定する必要のないマーケットプレイス用のアプリを作成したい場合は、https ://developers.google.com/google-apps/marketplace/tutorial_python_gae#Integrate-OAuth の手順に従ってください。
少なくとも利用可能な認証方法の理解から、以前にアクセスが許可されていたとしても、ユーザーがアプリケーションにログインしていない場合、Google の API のいずれにもアクセスできないと思います。
ユーザーがアプリ エンジン プロジェクト サービス アカウントを共有として追加すると、OAuth2 ダンスなしでいつでもアクセスできます。
アプリ エンジン プロジェクト サービス アカウントは次のようになります: example@appspot.gserviceaccount.com ここで情報を見つけることができます: 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)