我陷入了OAuthException 191的Facebook登录问题,如下图所示,重定向URI显示为“ http://zsize.openservice.or.th/callback/facebook” "OAuthException 191 - Can't Load URL: The domain of this URL isn't included in the app's domains
我认为有效OAUTH重定向URI出了点问题。但是,当我检查了我的Facebook API的“有效OAUTH重定向URI”部分(如下图所示)时,它已显示为由重定向URI验证程序验证的“ https://zsize.openservice.or.th/callback/facebook”。
这确实让我感到困惑,因为尽管我已经将OAUTH重定向URI更改为“ https://”,但是页面上显示“ OAuthException 191”的链接仍将重定向URI显示为“ http://”。 ”。如何处理这种错误?请帮助我。
哦,顺便说一句,与Facebook登录相关的代码在这里:
授权提供者:
@app.route('/authorize/<provider>',methods=['GET','POST'])
def oauth_authorize(provider):
try:
oauth = OAuthSignIn.get_provider(provider)
except ValueError:
return "Authorize Failure"
return oauth.authorize()
@app.route('/callback/<provider>',methods=['GET','POST'])
def oauth_callback(provider):
if not current_user.is_anonymous:
return redirect(url_for('timeline'))
回调提供者:
@app.route('/callback/<provider>',methods=['GET','POST'])
def oauth_callback(provider):
if not current_user.is_anonymous:
###print('Error - The current user is not anonymous','danger')
return redirect(url_for('timeline'))
###print('Start Callback sign in to Provider','info')
try:
oauth = OAuthSignIn.get_provider(provider) # problem arrise
social_id1, username1, email1, first_name1, last_name1, name1, gender1, profile_url1= oauth.callback()
except ValueError:
return render_template('index.html',error="callback failure")
except OAuthCallbackError as e:
return render_template('index.html',error=e.errors['error_code'] +" " +e.errors['error']+" : " +e.errors['error_description'])
if email1 is None:
email1 = ""
if db.getUserbySocialID(social_id1).get("id") is None: # if never login by this social account
db.regisUserSocial(social_id1, email1, datetime_now())
user = User(social_id = social_id1)
ImageDirectory = app.config['USER_IMAGE_DIRECTORY']
SocialIDString = str(social_id1)
CheckString = SocialIDString[0:6]
ImageFilename = str(username1) + '.jpg'
ImageFullDirectoryGlobal = ImageFilename
ImageURL = str(profile_url1)
r = requests.get(ImageURL)
if CheckString == 'facebo':
dirname = "FaceBook"
elif CheckString == 'google':
dirname = "Google"
SocialDirectory = dirname + SocialIDString[9:]
ImageSocialDirectoryGlobal = SocialDirectory
UserImageDirectory = ImageDirectory+SocialDirectory
UserImageDirectory = UserImageDirectory + '/'
ImageFullDirectoryGlobal = UserImageDirectory
if not os.path.exists(UserImageDirectory):
os.makedirs(UserImageDirectory)
ImageFullFilename = UserImageDirectory + ImageFilename
ImageFullFilenameGlobal = ImageFullFilename
with open(ImageFullFilename, 'wb') as f:
f.write(r.content)
ParsingImageDirectory = '../'+ImageDirectory
ParsingImageFile = ParsingImageDirectory +
ImageSocialDirectoryGlobal
ParsingImageFile = ParsingImageFile + '/'
ParsingImageFile = ParsingImageFile + ImageFilename
# TODO remove session
login_user(user)
current_user.logintype = "social"
current_user.confirmed = True
session['imglocation'] = ParsingImageFile +"?"+
str(datetime.datetime.now().strftime('%d%m%y%H%M%S%f'))
session['username'] = username1
session['nickname'] = name1
session['logged_in'] = True
session['logged_by'] = 'social'
session['confirmed'] = True
session['email'] = current_user.email
return redirect(url_for('timeline'))
如果您可以找到此OAuthException 191的解决方案,请帮助我: