इसलिए मैं google क्लाउड खोल से मेरी बोतल अनुप्रयोग चल रहा हूँ। इस ऐप्लिकेशन में उपयोगकर्ता अपने गूगल खाते के साथ प्रवेश करने की जरूरत है। मैं सभी आवश्यक बादल खोल लाइब्रेरी का उपयोग करने के लिए स्थापित।
जब मैं बादल खोल में अनुप्रयोग चलाने, गूगल खाते को चुनने के बाद मैं के साथ मेरी ऐप में प्रवेश करना चाहते हैं, इस त्रुटि ऊपर आता है
flask_oauth.OAuthException
OAuthException: Invalid response from google
सब कुछ ठीक काम करता है अगर मैं स्थानीय होस्ट से चलाने के।
मदद किसी भी तरह का अत्यधिक सराहना की है।
पुनश्च: यह कोड है
Flask.py:
import logging
from flask import Flask, render_template, redirect, url_for, session, make_response
from flask_oauth import OAuth
from urllib2 import Request, urlopen, URLError
import MySQLdb
import os
import json
Client_Id = my client id
Client_Secret = my client secret
Redirect_URI = '/callback'
SECRET_KEY = 'funny cat'
DEBUG = True
app = Flask(__name__)
app.debug = DEBUG
app.secret_key = SECRET_KEY
oauth = OAuth()
google = oauth.remote_app('google', base_url='https://www.google.com/accounts/', authorize_url='https://accounts.google.com/o/oauth2/auth', request_token_url=None, request_token_params={'scope': 'https://www.googleapis.com/auth/userinfo.profile', 'response_type': 'code'}, access_token_url='https://accounts.google.com/o/oauth2/token', access_token_method='POST', access_token_params={'grant_type': 'authorization_code'}, consumer_key=Client_Id, consumer_secret=Client_Secret)
@app.route('/')
def index():
return render_template(webpage1.html)
@app.route('/login',methods=['post','get'])
def login():
access_token = session.get('access_token')
if access_token is None:
return redirect(url_for('direct'))
access_token = access_token[0]
headers = {'Authorization': 'OAuth '+access_token}
req = Request('https://www.googleapis.com/oauth2/v1/userinfo',
None, headers)
try:
res = urlopen(req)
except URLError, e:
if e.code == 401:
session.pop('access_token', None)
return redirect(url_for('direct'))
return res.read()
data = json.load(res)
return render_template(webpage2.html, data = data)
@app.route('/direct')
def direct():
callback=url_for('authorized', _external=True)
return google.authorize(callback=callback)
@app.route(Redirect_URI)
@google.authorized_handler
def authorized(resp):
access_token = resp['access_token']
session['access_token'] = access_token, ''
return redirect(url_for('login'))
@app.route('/logout')
def logout():
session.pop('access_token', None)
return redirect(url_for('index'))
@google.tokengetter
def get_access_token():
return session.get('access_token')
if __name__ == __main__:
app.run(host='0.0.0.0', debug=True)
एपीआई में मेरे क्रेडेंशियल्स हैं
Authorized JavaScript origins : https://5000-dot-4778310-dot-devshell.appspot.com
Authorized redirect URIs : https://5000-dot-4778310-dot-devshell.appspot.com/callback
क्यों इस परियोजना का नाम एक ही ग्राहक आईडी और ग्राहक रहस्य के लिए अलग है?