y.s_
11/21/2023, 8:23 AMrp_st
11/21/2023, 8:27 AMrp_st
11/21/2023, 8:28 AMy.s_
11/21/2023, 8:29 AMrp_st
11/21/2023, 8:29 AMrp_st
11/21/2023, 8:30 AMy.s_
11/21/2023, 8:31 AMrp_st
11/21/2023, 8:31 AMy.s_
11/21/2023, 8:37 AMy.s_
11/21/2023, 9:45 AMy.s_
11/21/2023, 9:46 AMrp_st
11/21/2023, 9:48 AMrp_st
11/21/2023, 9:48 AMy.s_
11/21/2023, 9:50 AMrp_st
11/21/2023, 9:53 AMy.s_
11/21/2023, 9:55 AM@supertokens_blueprint.route("/test-refresh", methods=["GET","POST"])
def refresh_token():
url = "http://localhost:5000/auth/session/refresh"
try:
response = requests.post(url)
if response.status_code == 200:
access_token_expiration_time = datetime.utcnow() + timedelta(seconds=180)
access_token = response.headers.get("st-access-token")
resp = make_response("Refresh successful")
resp.set_cookie("sAccessToken", access_token, expires=access_token_expiration_time.strftime('%a, %d %b %Y %H:%M:%S GMT'), httponly=True, path="/", samesite='Lax')
return resp
else:
data = response.json()
return data['message']
except requests.RequestException as e:
return f"Error during refresh: {str(e)}", 500
rp_st
11/21/2023, 9:57 AMrp_st
11/21/2023, 9:57 AMy.s_
11/21/2023, 9:59 AMrp_st
11/21/2023, 10:01 AMy.s_
11/21/2023, 10:02 AM@supertokens_blueprint.route("/test-login", methods=["GET", "POST"])
def test_login():
url = "http://localhost:5000/auth/signin"
try:
response = requests.post(url, json=payload)
access_token = response.headers.get("st-access-token")
front_token = response.headers.get("front-token")
refresh_token = response.headers.get("st-refresh-token")
if access_token and front_token and refresh_token:
access_token_expiration_time = datetime.utcnow() + timedelta(seconds=180)
refresh_token_expiration_time = datetime.utcnow() + timedelta(days=1)
resp = make_response("Login successful")
resp.set_cookie("sAccessToken", access_token, expires=access_token_expiration_time.strftime('%a, %d %b %Y %H:%M:%S GMT'), httponly=True, path="/", samesite='Lax')
resp.set_cookie("sFrontToken", front_token, samesite='Lax')
resp.set_cookie("sRefreshToken", refresh_token , expires=refresh_token_expiration_time.strftime('%a, %d %b %Y %H:%M:%S GMT'), httponly=True, path="/", samesite='Lax')
return resp
else:
return "Missing tokens in the response headers", 500
this is the test-login, not sure whether i set the cookie correctlyrp_st
11/21/2023, 10:03 AMrp_st
11/21/2023, 10:03 AMy.s_
11/21/2023, 10:05 AMy.s_
11/21/2023, 10:07 AMrp_st
11/21/2023, 10:07 AMy.s_
11/21/2023, 10:09 AMrp_st
11/21/2023, 10:11 AMy.s_
11/21/2023, 10:12 AMrp_st
11/21/2023, 10:12 AMrp_st
11/21/2023, 10:13 AMy.s_
11/21/2023, 10:14 AMy.s_
11/21/2023, 10:15 AMrp_st
11/21/2023, 10:15 AMy.s_
11/21/2023, 10:17 AMrp_st
11/21/2023, 10:18 AMrp_st
11/21/2023, 10:18 AMy.s_
11/21/2023, 10:20 AMrp_st
11/21/2023, 10:21 AMrp_st
11/21/2023, 10:22 AMy.s_
11/21/2023, 10:22 AMrp_st
11/21/2023, 10:23 AM