ronflai
12/20/2022, 10:28 PM{
"errors": [
{
"errorType": "AuthorizerFailureException",
"message": "The adapter was unable to infer a handler to use for the event. This is likely related to how the Lambda function was invoked. (Are you testing locally? Make sure the request payload is valid for a supported handler.)"
}
]
}
Someone have any idea how to fix this ? Thanks.nkshah2
12/21/2022, 5:07 AMporcellus
12/21/2022, 8:59 AMronflai
12/21/2022, 9:14 AMuser_id
is used in the generate_allow
functionporcellus
12/21/2022, 9:58 AMronflai
12/21/2022, 11:45 AMsAccessToken
cookie with my backend domain but after refreshing the page the sAccessToken
and the sRefreshToken
disappear . Is it because we're not using the same domain between front and back ?porcellus
12/21/2022, 12:16 PMronflai
12/21/2022, 12:36 PM{}
and undefined
?porcellus
12/21/2022, 2:26 PMcustomClaim
into the access token payload?ronflai
12/21/2022, 2:28 PMporcellus
12/21/2022, 2:29 PMronflai
12/21/2022, 2:31 PMawait Session.attemptRefreshingSession();
just to test and I got a 401 but I have an existing sessionporcellus
12/21/2022, 2:33 PMronflai
12/21/2022, 2:58 PMporcellus
12/21/2022, 3:01 PMronflai
12/21/2022, 3:05 PMporcellus
12/21/2022, 3:06 PMronflai
12/21/2022, 3:07 PM{
"statusCode": 401,
"headers": {
"content-length": "26",
"id-refresh-token": "remove",
"access-control-expose-headers": "id-refresh-token",
"content-type": "application/json; charset=utf-8",
"access-control-allow-credentials": "****",
"access-control-allow-origin": "http://localhost:3001",
"vary": "Origin"
},
"multiValueHeaders": {
"set-cookie": [
"sAccessToken=\"\"; expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Path=/; SameSite=none; Secure",
"sIdRefreshToken=\"\"; expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Path=/; SameSite=none; Secure",
"sRefreshToken=\"\"; expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Path=/session/refresh; SameSite=none; Secure"
]
},
"body": "{\"message\":\"unauthorised\"}",
"isBase64Encoded": false
}
General:
Request URL: https://staging.api.lizy.io/auth/api/session/refresh
Request Method: POST
Status Code: 401
Remote Address: 54.192.111.7:443
Referrer Policy: strict-origin-when-cross-origin
Response Headers:
access-control-allow-credentials: true
access-control-allow-origin: http://localhost:3001
access-control-expose-headers: id-refresh-token
content-length: 26
content-type: application/json; charset=utf-8
date: Wed, 21 Dec 2022 15:16:54 GMT
id-refresh-token: remove
set-cookie: sAccessToken=""; expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Path=/; SameSite=none; Secure
set-cookie: sIdRefreshToken=""; expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Path=/; SameSite=none; Secure
set-cookie: sRefreshToken=""; expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; Path=/session/refresh; SameSite=none; Secure
vary: Origin
via: 1.1 d3dc7fce70a4cf01f01f6bf06755098c.cloudfront.net (CloudFront)
x-amz-apigw-id: dgJ4HFaqFiAFYlA=
x-amz-cf-id: ZMSacDcpMOL7FEoAkKlZhV4NMTXGVcmWgI3ekY3gUZS8XUZOmVr8oQ==
x-amz-cf-pop: MRS52-P2
x-amzn-remapped-content-length: 26
x-amzn-requestid: 822ea0b4-3143-4aa0-88b9-e61d66b514da
x-amzn-trace-id: Root=1-63a32366-167c0d65779e98173ef0df8a;Sampled=0
x-cache: Error from cloudfront
Response:
{"message":"unauthorised"}
porcellus
12/21/2022, 3:23 PMronflai
12/21/2022, 3:35 PMauthority: staging.api.lizy.io
:method: POST
:path: /auth/api/session/refresh
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: no-cache
content-length: 0
cookie: sAccessToken="eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsInZlcnNpb24iOiIyIn0%3D.eyJzZXNzaW9uSGFuZGxlIjoiZmMyYTYwMjAtNjg4MC00ZGM2LTlmMDQtZTcyZDk2MjcwMWI0IiwidXNlcklkIjoiOGQ3NzcxZjgtYmU1Ni00YTBmLTlkMGUtMTkyZDMxNGFlZGE3IiwicmVmcmVzaFRva2VuSGFzaDEiOiJlM2RiNWQ0MThhMzc0MzI1NjM1ZmYwYzMzMTA1YmE1NmJlYTI0Y2VlYWI0MzEzZTAzZDllNDAzMzU4ODA4MDZmIiwicGFyZW50UmVmcmVzaFRva2VuSGFzaDEiOm51bGwsInVzZXJEYXRhIjp7fSwiYW50aUNzcmZUb2tlbiI6bnVsbCwiZXhwaXJ5VGltZSI6MTY3MTY0MDYyNjYwOSwidGltZUNyZWF0ZWQiOjE2NzE2MzcwMjY2MDksImxtcnQiOjE2NzE2MzcwMjY2MDl9.G6IfZRX9pm9RlMZKz4Gmq6v7mDg9iQH9GokcYJGikfzCi9I5xNmqdOUohzDstd7dFY8siqKTCoibUnFjqpJGSHlgoLiC7YFia2ssBz6bFaEH9PPYtiRPVpFf/ijw6S7UzlQTIzvhkApqIz1tLwe7FDEiRf8Csv5qwOa0b60YLZXJl/3nbWN5X%2BZgW6QiczOdRED%2BfaZdZ54CBedHXOsgrAhvX1dYJoihoiuf9E4VKe0o5mH3irW2cSMCuacmnBucS6ETokcjf2VDhccy2uzYMoPwNWIyyReexHgYRityMpTcJnihO3nmMZDYsWKvJiAbBRIFmZBOnUZha9q8mBvYLA%3D%3D"; sIdRefreshToken=d100f5a1-69bd-4fb6-bd55-9bc554bacbb4
fdi-version: 1.8,1.9,1.10,1.11,1.12,1.13,1.14,1.15
origin: http://localhost:3001
pragma: no-cache
referer: http://localhost:3001/
rid: session
sec-ch-ua: "Not?A_Brand";v="8", "Chromium";v="108", "Brave";v="108"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Linux"
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: cross-site
sec-gpc: 1
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
porcellus
12/21/2022, 3:47 PMronflai
12/21/2022, 3:50 PMporcellus
12/21/2022, 3:57 PMapiBasePath
on the frontend to include the gateway path as well.apiBasePath
settings on the frontend and backend do not match. If they do, there is some other issue.ronflai
12/21/2022, 3:59 PMporcellus
12/21/2022, 4:05 PMronflai
12/21/2022, 4:35 PMapi_gateway_path=f"/{get_current_stage()}"
in the backend config but it did not work and I noticed that for the api_domain
setting we are using api_domain = (
"https://api.lizy.io"
if get_current_stage() == Stage.PROD
else f"https://{get_current_stage()}.api.lizy.io"
)
so it should already have the notion of stageSuperTokens.init({
appInfo: {
apiDomain:
process.env.BACKEND == "production"
? "https://api.lizy.io"
: "https://staging.api.lizy.io",
apiBasePath: "/auth/api",
appName: "Lizy authentication",
},
recipeList: [Session.init(), Passwordless.init()],
});
api_domain = (
"https://api.lizy.io"
if get_current_stage() == Stage.PROD
else f"https://{get_current_stage()}.api.lizy.io"
)
website_domain = (
"https://www.lizy.be" if get_current_stage() == Stage.PROD else "https://staging.www.lizy.be/"
)
init(
app_info=InputAppInfo(
app_name="Lizy authentication services",
api_domain=api_domain,
website_domain=website_domain,
api_base_path="/",
website_base_path="/auth",
),
supertokens_config=SupertokensConfig(
connection_uri= ********,
api_key= ********
),
framework="fastapi",
recipe_list=[
session.init(cookie_same_site="none"),
passwordless.init(
flow_type="MAGIC_LINK",
contact_config=ContactEmailOnlyConfig(),
),
],
mode="asgi",
)
api_base_path
is "/" because we also have handler = Mangum(app, api_gateway_base_path="/auth/api")
porcellus
12/21/2022, 5:07 PMapiBasePath
needs match on the frontend and backend./auth/api
as the api_gateway_path on the backendronflai
12/21/2022, 5:17 PMporcellus
12/21/2022, 5:30 PM