File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed
Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,9 @@ def create_token(
101101 if user_id is None or user_id == "" :
102102 raise ValueError ("user_id is required" )
103103
104- return self ._create_token (user_id = user_id , expiration = expiration )
104+ return self ._create_token (
105+ user_id = user_id , expiration = expiration , iat = int (time .time ()) - 5
106+ )
105107
106108 def create_call_token (
107109 self ,
@@ -111,7 +113,11 @@ def create_call_token(
111113 expiration : int = None ,
112114 ):
113115 return self ._create_token (
114- user_id = user_id , call_cids = call_cids , role = role , expiration = expiration
116+ user_id = user_id ,
117+ call_cids = call_cids ,
118+ role = role ,
119+ expiration = expiration ,
120+ iat = int (time .time () - 5 ),
115121 )
116122
117123 def _create_token (
@@ -121,13 +127,14 @@ def _create_token(
121127 call_cids : List [str ] = None ,
122128 role : str = None ,
123129 expiration = None ,
130+ iat : int = None ,
124131 ):
125132 now = int (time .time ())
126133
127- claims = {
128- # generate token valid from 5 seconds ago to avoid unauthorized error due to clock skew
129- " iat" : now - 5 ,
130- }
134+ claims = {}
135+
136+ if iat is not None :
137+ claims [ "iat" ] = iat
131138
132139 if channel_cids is not None :
133140 claims ["channel_cids" ] = channel_cids
You can’t perform that action at this time.
0 commit comments