すべてのクライアント/ SDKを正式に文書化したアプリケーションを作成しました。Appengine FlexサービスアカウントでDriveフォルダにアクセスするためのアクセス権が不十分です
credentials = GoogleCredentials \
.get_application_default() \
.create_scoped('https://www.googleapis.com/auth/drive')
drive = discovery.build(
'drive',
'v3',
http=self.credentials.authorize(Http())
)
drive.files() \
.get(fileId=file_id) \
.execute()
それはパネルから生成されたサービスアカウントにローカルで完璧に動作しますが、私は、アプリケーション、AppEngineの柔軟な環境内のサービスアカウントを展開するときに問題に実行されます。
17:15:04.000 /env/lib/python3.4/site-packages/oauth2client/contrib/gce.py:99: UserWarning: You have requested explicit scopes to be used with a GCE service account. 17:15:04.000 Using this argument will have no effect on the actual scopes for tokens 17:15:04.000 requested. These scopes are set at VM instance creation time and 17:15:04.000 can't be overridden in the request. 17:15:04.000 17:15:04.000 warnings.warn(_SCOPES_WARNING) 17:15:04.000 INFO:googleapiclient.discovery:URL being requested: GET https://www.googleapis.com/discovery/v1/apis/drive/v3/rest 17:15:04.000 INFO:oauth2client.client:Attempting refresh to obtain initial access_token 17:15:04.000 INFO:googleapiclient.discovery:URL being requested: GET https://www.googleapis.com/drive/v3/files/0B0Kn....M1pBNFE?alt=json 17:15:04.000 ERROR:root:Failed to retrieve file 0B0K....M1pBNFE. Is it shared with me? [email protected] 17:15:04.000 Traceback (most recent call last): 17:15:04.000 File "/home/vmagent/app/script.py", line 45, in get 17:15:04.000 .execute() 17:15:04.000 File "/env/lib/python3.4/site-packages/oauth2client/util.py", line 135, in positional_wrapper 17:15:04.000 return wrapped(*args, **kwargs) 17:15:04.000 File "/env/lib/python3.4/site-packages/googleapiclient/http.py", line 760, in execute 17:15:04.000 raise HttpError(resp, content, uri=self.uri) 17:15:04.000 googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/drive/v3/files/0B0Kn....M1pBNFE?alt=json returned "Insufficient Permission">
私は権限をチェックしていると、彼らはすべてのセットです。この問題は、スコープされた資格情報を作成しようとしているときに表示される「この引数を使用すると効果がありません...」というメッセージが原因である可能性があります。
これを達成するためにどのような記事やガイドがありますか?あなたはリンクを提供できますか? – Nicholas
上記のコードを使用すると、私はこの問題を再現できません。ドライブAPIはAPIの下でデベロッパーコンソールで有効になっていますか?エラーメッセージは、GCEインスタンス(GAEアプリケーションではない)で使用されるスコープを示します。このコードはどこで実行されていますか? – Nicholas
@Nicholasこれは上流のバグです。https://code.google.com/p/googleappengine/issues/detail?id=12970 – txomon