2017-12-12 4 views
0

나는이 질문에 대한 특별한 대답을 찾고있는 SO와 SE의 모든 곳곳에서 해답을 찾을 수없는 것처럼 보입니다. 파이썬 플라스크를 사용하여 Google 캘린더에 액세스하고 조건에 따라 캘린더를 작성하는 간단한 웹 응용 프로그램을 작성합니다. 내 문제는 OAuth2와 redirect_uris 올바른지고. 아래 코드는, 내 코드를 실행하려고 할 때마다 리디렉션 URI가 잘못되어 응용 프로그램이 더 이상 진행되지 않는다는 오류가 발생합니다. 리디렉션 URI는 http://localhost:8080입니다. 리디렉션 URI를 내 개발자 콘솔에 추가하고 tailing '/ oauth2callback'과 함께 URI를 추가하는 설정을 시도했습니다 ('/'가있는 경우와없는 경우). 또한 다른 URI를 완전히 지정하려고 시도했지만 오류가 http://localhost:8080을 계속 언급하고 다른 client_secret.json 파일을 사용하고 flow_from_client_secrets에 다른 URI를 지정하더라도 다른 모든 리디렉션 URI를 인식하지 못하는 것 같습니다. 또한 크롬을 시크릿 모드로 실행할 때마다 스크립트를 실행하기 전에 캐시를 삭제했습니다. 아무것도 도움이되는 것 같지 않습니다. 나는 그것이 단순해야만한다는 것을 알고 있습니다. 만약 누군가가 그것이 무엇인지를 지적 할 수 있다면, 저는 매우 감사하게 생각합니다!Python Flask의 OAuth 웹 애플리케이션 용 Google 캘린더 API

SCOPES = 'https://www.googleapis.com/auth/calendar' 
CLIENT_SECRET_FILE = 'client_secret_web.json' 
APPLICATION_NAME = 'Example Calendar Application' 
REDIRECT_URI = 'http://placeholder.com/oauth2callback' 

home_dir = os.path.expanduser('~') 
    credential_dir = os.path.join(home_dir, '.credentials') 
    if not os.path.exists(credential_dir): 
     os.makedirs(credential_dir) 
    redirect_uri="" 
    credential_path = os.path.join(credential_dir, 
            'calendar-python-quickstart.json') 

    store = Storage(credential_path) 
    credentials = store.get() 
    flow = client.flow_from_clientsecrets(self.CLIENT_SECRET_FILE, 
    self.SCOPES, prompt='consent', redirect_uri=self.REDIRECT_URI) 
    flow.user_agent = self.APPLICATION_NAME 
    if self.flags: 
     credentials = tools.run_flow(flow, store, self.flags) 
    else: # Needed only for compatibility with Python 2.6 
     credentials = tools.run(flow, store) 

     print('Storing credentials to ' + credential_path) 
    return credentials 
+0

이 대답 할 수있는 사람이 물어 있도록 ~/.credentials/달력 파이썬 quickstart.json에서 만든 파일을 삭제해야 생각? 나는 정직하게 벽에 머리를 치고 꽤 오랫동안 지냈다. 아직도 작동하는 답변을 추적 할 수 없었습니다. – Jake

답변

0

나는 당신이 프로그램을 다시 권한에 대한