0

次のコードgoogleドライブの[認証]ボタンをクリックした後、404リソースが見つかりませんでした。私のコードは私が間違ってやっていることの下にあります。Google App Engine oauth2コールバック404

from __future__ import print_function 
 
import httplib2 
 
import os 
 

 
from apiclient import discovery 
 
from oauth2client import client 
 
from oauth2client import tools 
 
from oauth2client.file import Storage 
 
from apiclient.discovery import build 
 
from google.appengine.ext import webapp 
 
from oauth2client.appengine import OAuth2DecoratorFromClientSecrets 
 

 
import webapp2 
 

 

 

 
try: 
 
    import argparse 
 
    flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() 
 
except ImportError: 
 
    flags = None 
 
except SystemExit: 
 
    flags= None 
 
# 
 
## If modifying these scopes, delete your previously saved credentials 
 
## at ~/.credentials/drive-python-quickstart.json 
 
SCOPES = 'https://www.googleapis.com/auth/drive' 
 
CLIENT_SECRET_FILE = 'client_secret.json' 
 
APPLICATION_NAME = 'Drive API Quickstart' 
 

 
decorator = OAuth2DecoratorFromClientSecrets(CLIENT_SECRET_FILE,SCOPES) 
 

 
service = build('drive', 'v3') 
 

 
class MainHandler(webapp.RequestHandler): 
 

 
    @decorator.oauth_required 
 
    def get(self): 
 
    # Get the authorized Http object created by the decorator. 
 
    http = decorator.http() 
 
    # Call the service using the authorized Http object. 
 
    request = service.files().list(q = "mimeType != 'application/vnd.google-apps.folder'", pageSize=1000, ) 
 
    response = request.execute(http=http) 
 
    
 
app = webapp.WSGIApplication([ 
 
    ('/', MainHandler), 
 
], debug=True)

私は、正しいURLをリダイレクト場合考えリダイレクトなどの終わりに/とないhttps://drive-156701.appspot.com/oauth2callbackがありますか? ありがとうございます!

答えて

0

/oauth2callbackのURLハンドラがありません。 /のURLハンドラのみがあります。

app = webapp.WSGIApplication([ 
    ('/oauth2callback', Oauth2CallbackHandler), 
    ('/', MainHandler), 
], debug=True) 
とコールバックを処理するための Oauth2CallbackHandlerクラスを作る:試してみてください。含むことに加えて

0

アプリ= webapp2.WSGIApplication( [ ( '/'、MainHandler)、 (decorator.callback_path、decorator.callback_handler())、 ]、 デバッグ= true)

@ decorator.oauth_requiredは、あなたのコールバックを処理します。

このビデオをチェックしてください:https://www.youtube.com/watch?v=HoUdWBzUZ-M ローカルホスト開発とデプロイメントの両方のための認証情報を作成する必要があります。

そして、あなたがチェックアウトしていることを確認してください:https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27 あなたのAPIの輸入は詳細ここで、サードパーティ製の輸入品のように扱われている必要があります https://developers.google.com/api-client-library/python/start/installation