【发布时间】:2023-05-15 23:01:01
【问题描述】:
我正在使用Actions on Google(在手机上Google Assistant)并使用它的Account Linking登录Auth0(登录窗口 :
image)。
但是,我想随时从Auth0 注销,以便从头开始测试整个过程。
我在 Auth0 文档 (https://auth0.com/docs/logout) 之后在 Python 和 Flask 中编写了以下源代码。
from flask import Flask, render_template, request, jsonify
import requests
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def index():
session['user'] = 'Poete_Maudit'
data = request.get_json()
if data is not None:
action = data["queryResult"]["action"]
else:
return 'HERE'
# Triggers actions.intent.SIGN_IN which leads to Auth0
if (action == 'sign'):
return jsonify({"payload": {
"google": {
"expectUserResponse": True,
"isSsml": False,
"noInputPrompts": [],
"systemIntent": {
"data": {
"@type": "type.googleapis.com/google.actions.v2.SignInValueSpec"
},
"intent": "actions.intent.SIGN_IN"
}
}
}
})
# I have other if statements below which retrieve the access token
# and do in general other stuff on Actions on Google app
# but it is too long to include it here
@app.route('/logout')
def logout():
session.clear()
return redirect('https://project_id.eu.auth0.com/v2/logout?returnTo=http://127.0.0.1:5000')
if __name__== "__main__":
app.secret_key = os.urandom(24)
app.run(debug=True)
在我执行了整个登录过程后,我手动(从浏览器)转到http://127.0.0.1:5000/logout,它成功地将我重定向到http://127.0.0.1:5000。在 python 控制台我得到:
127.0.0.1 - - [06/Jun/2018 14:09:04] "GET /logout HTTP/1.1" 302 -
127.0.0.1 - - [12/Jun/2018 11:03:16] "GET / HTTP/1.1" 200 -
在Auth0 日志部分,我收到了Success Logout (image)。
但是,当我再次在手机 Google Assistant 上重新启动整个过程时,登录窗口并没有出现,我再次以相同的方式登录 Auth0 accessToken.
我怎样才能通过清除会话和/或http://127.0.0.1:5000 上的 cookie 来正确注销,从而使 Auth0 登录窗口再次出现?
附:
1) 请记住,目前我正在使用Python 和ngrok 进行所有这些操作。如果我重新启动 ngrok 会话,那么登录窗口会重新出现,但显然我想以编程方式执行此操作。
2) 请不要把任何事情视为理所当然。我在做的事情中可能遗漏了一些非常基本的东西,所以请随时问我一些非常基本的问题。
【问题讨论】:
标签: python flask auth0 actions-on-google ngrok