https://supertokens.com/ logo
#support-questions
Title
# support-questions
e

execreate

07/13/2022, 5:01 AM
Hey guys, I am using
supertokens-python==0.8.2
with
Django==4.0.6
and resend code is not working for passwordless. Is it a known issue for python SDK version I am using? It is a POST request from frontend to the URL
signinup/code/resend
with
preAuthSessionId
and
deviceId
payload. The response says
"status": "OK"
with 200 status, and the code is not being delivered. I cannot see any logs on the backend that indicate code resend attempt.
We have self-hosted
supertokens-core==v3.14.0
r

rp

07/13/2022, 5:48 AM
Hey @execreate let us have a look. There is no such known issue.
k

KShivendu

07/13/2022, 5:49 AM
Can you please share your supertokens init snippet?
e

execreate

07/13/2022, 5:55 AM
Sure, one moment
Copy code
python
from supertokens_python import init, InputAppInfo, SupertokensConfig
from supertokens_python.recipe import passwordless, session
from supertokens_python.recipe.passwordless import ContactPhoneOnlyConfig

from apps.mysupertokens.otp_delivery import async_send_text_message
from apps.mysupertokens.overrides import override_functions


def init_supertokens(site_url,
                     website_domain,
                     website_base_path,
                     connection_uri,
                     api_key):
    # ensure cookie domain is '.example.com' if api is hosted on a subdomain
    cookie_domain = site_url.removeprefix("http://").removeprefix("https://")
    if len(cookie_domain.split(".")) > 2:
        cookie_domain = "." + ".".join(cookie_domain.split(".")[-2:])

    init(
        app_info=InputAppInfo(
            app_name="medhub",
            api_domain=site_url,
            api_base_path="/auth",
            website_domain=website_domain,
            website_base_path=website_base_path,
        ),
        supertokens_config=SupertokensConfig(
            connection_uri=connection_uri,
            api_key=api_key,
        ),
        framework='django',
        recipe_list=[
            session.init(
                override=session.InputOverrideConfig(functions=override_functions),
                cookie_domain=cookie_domain,
            ),
            passwordless.init(
                flow_type="USER_INPUT_CODE",
                contact_config=ContactPhoneOnlyConfig(
                    create_and_send_custom_text_message=async_send_text_message
                )
            )
        ],
        mode='wsgi',
    )
override_functions
override
create_new_session
to ensure that access token contains user roles;
r

rp

07/13/2022, 6:08 AM
Does the
async_send_text_message
function get called when you click on the resend button?
e

execreate

07/13/2022, 6:11 AM
No. I know it for sure, because we have a golang telegram bot service which delivers OTPs. It does not get called on resend.
r

rp

07/13/2022, 6:12 AM
I see. But it gets sent during the initial login?
e

execreate

07/13/2022, 6:12 AM
Yes, it gets called and OTP is delivered immediately
on initial login
r

rp

07/13/2022, 6:12 AM
I see.
Can you upgrade to a newer version of the SDK? This issue might have been solved already.
e

execreate

07/13/2022, 6:13 AM
I thought so too. I'll try to upgrade SDK version on our staging env and let you know if the issue is resolved.
It's gonna take an hour or so
k

KShivendu

07/13/2022, 6:13 AM
Sure. Keep us posted.
e

execreate

07/13/2022, 8:25 AM
Resend code works just fine with
supertokens-python==0.10.1
🎉
2 Views