I have an application in which, a URL is to be clicked for financial transactions, so for security reasons, I want to disable this link after a specific time, but the problem is link has not expired even after a specific time period as the code is deployed in one time zone and client is using the app on another time zone. The URL is expiring randomly.

I want to synchronize with the time period specified for the URL to expire so that the URL will be disabled after a specific time when the client uses the app anywhere across time zones.

I have tried various approaches:

Approach 1: Using time #PYTHON

import time

expiration_time = int(time.time()) + 20

url_temp = f"https://example.com?expiration_time={expiration_time}"

Approach 2: Using HTML

If we modify the HTML page, then it can't work in the app. Also, we don't want to use this approach, as this will not work in the connecting application

Approach 3: Using normal UTC #PYTHON

from datetime import datetime, timezone

utc_time = datetime.utcnow().replace(tzinfo=timezone.utc)

utc_time_str = utc_time.strftime("%Y-%m-%d %H:%M:%S.%f%z+00:00")

utc_time_format = datetime.strptime(utc_time_str, "%Y-%m-%d %H:%M:%S.%f%z+00:00")

expiration_time = int(utc_time_format.timestamp()) + 20

url_temp = f"https://example.com?expiration_time={expiration_time}"

Approach 4: Using UTC with timedelta #PYTHON

from datetime import datetime, timezone,timedelta

utc_time = datetime.utcnow().replace(tzinfo=timezone.utc)

expire_time_modify = utc_time + timedelta(seconds=20)

expiration_time = int(utc_time_format.timestamp())

0

There are 0 best solutions below