@@ -37,7 +37,7 @@ def __init__(self, api_key, api_secret, api_url='https://api.opentok.com'):
37
37
self .api_secret = api_secret
38
38
self .api_url = api_url
39
39
40
- def generate_token (self , session_id , role = Roles .publisher , expire_time = None , connection_data = None , ** kwargs ):
40
+ def generate_token (self , session_id , role = Roles .publisher , expire_time = None , data = None ):
41
41
"""
42
42
Generate a token which is passed to the JS API to enable widgets to connect to the Opentok api.
43
43
session_id: Specify a session_id to make this token only valid for that session_id.
@@ -69,8 +69,8 @@ def generate_token(self, session_id, role=Roles.publisher, expire_time=None, con
69
69
raise OpenTokException (u ('Cannot generate token, expire_time is not in the future {0}' ).format (expire_time ))
70
70
if expire_time > now + (60 * 60 * 24 * 30 ): # 30 days
71
71
raise OpenTokException (u ('Cannot generate token, expire_time is not in the next 30 days {0}' ).format (expire_time ))
72
- if (connection_data is not None ) and len (connection_data ) > 1000 :
73
- raise OpenTokException (u ('Cannot generate token, connection_data must be less than 1000 characters' ).format (connection_data ))
72
+ if (data is not None ) and len (data ) > 1000 :
73
+ raise OpenTokException (u ('Cannot generate token, data must be less than 1000 characters' ).format (data ))
74
74
75
75
# decode session id to verify api_key
76
76
sub_session_id = session_id [2 :]
@@ -89,7 +89,7 @@ def generate_token(self, session_id, role=Roles.publisher, expire_time=None, con
89
89
create_time = now ,
90
90
expire_time = expire_time ,
91
91
role = role .value ,
92
- connection_data = (connection_data or None ),
92
+ connection_data = (data or None ),
93
93
nonce = random .randint (0 ,999999 )
94
94
)
95
95
data_string = urlencode (data_params , True )
@@ -151,7 +151,7 @@ def create_session(self, location=None, p2p=False):
151
151
raise AuthError ('Failed to create session (code=%s): %s' % (error .attributes ['code' ].value , error .firstChild .attributes ['message' ].value ))
152
152
153
153
session_id = dom .getElementsByTagName ('session_id' )[0 ].childNodes [0 ].nodeValue
154
- return Session (session_id , location = location , p2p = p2p )
154
+ return Session (self , session_id , location = location , p2p = p2p )
155
155
except Exception as e :
156
156
raise OpenTokException ('Failed to generate session: %s' % str (e ))
157
157
0 commit comments