bert2002
09/24/2022, 4:19 AMFastAPI
and I would believe that the Middleware
will add the /auth
endpoints (set website_base_path) to the fastapi application, but it does not. I dont see any errors though. I tried the example from github, but no success ( https://github.com/supertokens/supertokens-python/blob/master/examples/with-fastapi/with-thirdpartyemailpassword/main.py )bert2002
09/24/2022, 4:20 AMINFO: 127.0.0.1:39268 - "POST /auth/signinup/code HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:39270 - "POST /signinup/code HTTP/1.1" 404 Not Found
bert2002
09/24/2022, 4:20 AMrp_st
09/24/2022, 4:22 AMrp_st
09/24/2022, 4:22 AMbert2002
09/24/2022, 4:25 AMbert2002
09/24/2022, 4:26 AMapi_1 | com.supertokens {"t": "2022-09-24T04:25:58.816Z", "sdkVer": "0.11.0", "message": "middleware: Not handling because request path did not start with config path. Request path: //auth/signinup/code", "file": "supertokens.py:543"}
api_1 |
api_1 | DEBUG: {"t": "2022-09-24T04:25:58.816Z", "sdkVer": "0.11.0", "message": "middleware: Not handling because request path did not start with config path. Request path: //auth/signinup/code", "file": "supertokens.py:543"} (line:543)
api_1 | INFO: 172.20.0.1:54494 - "POST /auth/signinup/code HTTP/1.1" 404 Not Found
rp_st
09/24/2022, 4:26 AMrp_st
09/24/2022, 4:26 AM//auth/signinup/code
- did you add a double //
at the start of the request?bert2002
09/24/2022, 4:27 AM# curl -X POST http://127.0.0.1:8000/auth/signinup/code
bert2002
09/24/2022, 4:27 AM/
in the config and try againrp_st
09/24/2022, 4:28 AMhttp://127.0.0.1:8000
bert2002
09/24/2022, 4:28 AMapi_domain="http://localhost:8000",
website_domain="http://localhost:8000",
api_base_path="auth",
website_base_path="auth"
bert2002
09/24/2022, 4:29 AMrp_st
09/24/2022, 4:29 AM//auth/signinup/code
when it's /auth/signinup/code
bert2002
09/24/2022, 4:29 AM/auth
at the startup api_1 | DEBUG: {"t": "2022-09-24T04:29:15.480Z", "sdkVer": "0.11.0", "message": "app_info: {
api_1 | "api_base_path": "/auth",
api_1 | "api_domain": "http://localhost:8000",
api_1 | "api_gateway_path": "",
api_1 | "app_name": "Patchwork",
api_1 | "framework": "fastapi",
api_1 | "mode": "asgi",
api_1 | "website_base_path": "/auth",
api_1 | "website_domain": "http://localhost:8000"
api_1 | }", "file": "supertokens.py:210"} (line:210)
rp_st
09/24/2022, 4:30 AMbert2002
09/24/2022, 4:30 AMapi_base_path
does have no /
rp_st
09/24/2022, 4:31 AMbert2002
09/24/2022, 4:31 AMbert2002
09/24/2022, 4:31 AMapi_base_path="auth",
website_base_path="auth"
bert2002
09/24/2022, 4:31 AM/auth
rp_st
09/24/2022, 4:32 AMrp_st
09/24/2022, 4:32 AM//auth/signinup/code
rp_st
09/24/2022, 4:32 AMrp_st
09/24/2022, 4:35 AMbert2002
09/24/2022, 4:47 AMcom.supertokens {"t": "2022-09-24T04:46:20.518Z", "sdkVer": "0.11.0", "message": "middleware: Started", "file": "supertokens.py:536"}
com.supertokens {"t": "2022-09-24T04:46:20.519Z", "sdkVer": "0.11.0", "message": "middleware: requestRID is: None", "file": "supertokens.py:549"}
com.supertokens {"t": "2022-09-24T04:46:20.519Z", "sdkVer": "0.11.0", "message": "middleware: Checking recipe ID for match: session", "file": "supertokens.py:573"}
com.supertokens {"t": "2022-09-24T04:46:20.520Z", "sdkVer": "0.11.0", "message": "middleware: Checking recipe ID for match: emailverification", "file": "supertokens.py:573"}
com.supertokens {"t": "2022-09-24T04:46:20.521Z", "sdkVer": "0.11.0", "message": "middleware: Checking recipe ID for match: thirdpartyemailpassword", "file": "supertokens.py:573"}
com.supertokens {"t": "2022-09-24T04:46:20.523Z", "sdkVer": "0.11.0", "message": "middleware: Not handling because no recipe matched", "file": "supertokens.py:586"}
INFO: 127.0.0.1:39292 - "POST /auth/signinup/code HTTP/1.1" 404 Not Found
rp_st
09/24/2022, 4:47 AMKShivendu
09/24/2022, 4:49 AMbert2002
09/24/2022, 4:52 AM# curl -X POST http://127.0.0.1:3001/auth/signin
{"message":"Are you sending too many / too few formFields?"}
and result INFO: 127.0.0.1:39302 - "POST /auth/signin HTTP/1.1" 400 Bad Request
bert2002
09/24/2022, 4:53 AMinit(
supertokens_config=SupertokensConfig(
connection_uri="http://supertokens:3567",
api_key=os.environ.get("SUPERTOKENS_API_KEY")
),
app_info=InputAppInfo(
app_name="Patchwork",
api_domain="http://localhost:8000",
website_domain="http://localhost:8000",
api_base_path="/auth",
website_base_path="/auth"
),
framework="fastapi",
recipe_list=[
session.init(),
emailverification.init("REQUIRED"),
thirdpartypasswordless.init(
flow_type="USER_INPUT_CODE_AND_MAGIC_LINK",
contact_config=ContactEmailOnlyConfig(),
#email_delivery=EmailDeliveryConfig(
# service=thirdpartypasswordless.SMTPService(
# smtp_settings=smtp_settings
# )
#)
),
thirdpartyemailpassword.init(
providers=[
Google(
is_default=True,
client_id=os.environ.get("GOOGLE_CLIENT_ID"),
client_secret=os.environ.get("GOOGLE_CLIENT_SECRET"),
)
]
),
],
telemetry=False,
mode='asgi'
)
bert2002
09/24/2022, 4:56 AMapp = FastAPI(
root_path=os.environ.get('FASTAPI_ROOT_PATH'),
)
and root_path
is set to /
KShivendu
09/24/2022, 5:03 AMKShivendu
09/24/2022, 5:03 AMbert2002
09/24/2022, 5:09 AMroot_path
it works, e.g.
app = FastAPI()
and the supertoken config like this:
app_info=InputAppInfo(
app_name="Patchwork",
api_domain="http://localhost:8000",
website_domain="http://localhost:8000",
api_base_path="/auth",
website_base_path="/auth"
),
Then I can reach eh api e.g. # curl http://localhost:8000/auth/signin -X POST
{"message":"Are you sending too many / too few formFields?"}
KShivendu
09/24/2022, 5:09 AMKShivendu
09/24/2022, 5:10 AMbert2002
09/24/2022, 5:11 AMroot_path
it will not work anymore e.g.
app = FastAPI(
root_path="/api",
)
and the config (doesnt matter actually, always the same)
app_info=InputAppInfo(
app_name="Patchwork",
api_domain="http://localhost:8000",
website_domain="http://localhost:8000",
api_base_path="/auth",
website_base_path="/auth"
),
then we get:
# curl http://localhost:8000/api/auth/signin -X POST
{"detail":"Not Found"}
and
api_1 | DEBUG: {"t": "2022-09-24T05:10:45.061Z", "sdkVer": "0.11.0", "message": "middleware: Not handling because request path did not start with config path. Request path: /api/api/auth/signin", "file": "supertokens.py:543"} (line:543)
bert2002
09/24/2022, 5:11 AMroot_path
of the FastAPI() is set, it duplicates itbert2002
09/24/2022, 5:12 AMKShivendu
09/24/2022, 5:13 AMbert2002
09/24/2022, 5:22 AMKShivendu
09/26/2022, 9:49 AM