0

Google ドライブ API を使用して Google ドライブのファイルを一覧表示する AppEngine アプリケーションを開発しています。ユーザーの 1 人がアプリを実行しようとすると、500 エラーが発生します。

HttpError: https://www.googleapis.com/drive/v2/files?q=%27[ID サニタイズ]%27+in+parents&alt=json&maxResults=5 が「無効な資格情報」を返しました">

このコードは、特定の Google ドライブ フォルダーからファイルをプルします。フォルダとファイルはユーザーと共有され、アプリは Google Drive API の使用を承認されます。

ある時点で、ゼロから始めなければならないと考えたので、そのユーザーのアカウントから承認を取り消しました。違いはないように見えましたが、怪我よりも侮辱を加えるために、私のアプリはその特定のユーザーに承認を求めなくなったようです。

この時点で誰か推奨事項はありますか?私のコードでは、承認を処理するために Python 用の Google API クライアントとデコレータ (oauth_required を使用) を使用しています。

CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secrets.json')

MISSING_CLIENT_SECRETS_MESSAGE = """
<h1>Warning: Please configure OAuth 2.0</h1>
<p>
To make this sample run you will need to populate the client_secrets.json file
found at:
</p>
<p>
<code>%s</code>.
</p>
<p>with information found on the <a
href="https://code.google.com/apis/console">APIs Console</a>.
</p>
""" % CLIENT_SECRETS

http = httplib2.Http(memcache)

service = build("plus", "v1", http=http)
files_service = build("drive", "v2", http=http)

decorator = oauth2decorator_from_clientsecrets(
    CLIENT_SECRETS,
    scope='https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/drive.readonly',
    message=MISSING_CLIENT_SECRETS_MESSAGE)

[...]

class MainPage(webapp2.RequestHandler):

    @decorator.oauth_required
    def get(self):

[...]

        try:
            kb_param = {}
            kb_param["maxResults"] = 5
            kb_param["q"] = "'[sanitized]' in parents"
            kb_files = files_service.files().list(**kb_param).execute(http=http)

            template_values = {
                'kb_files': kb_files["items"]
            }

どんな洞察も大歓迎です:)

ありがとう!リック。

4

1 に答える 1

0

トークンが取り消されているか、資格情報が実際に間違っている可能性があります。

于 2013-01-22T05:19:00.923 に答える