@@ -246,6 +246,45 @@ def activate(token, rsa_pub_key, product_id, key, machine_code, fields_to_return
246246 except Exception :
247247 return (None , "The signature check failed." )
248248
249+ @staticmethod
250+ def get_key (token , rsa_pub_key , product_id , key , fields_to_return = 0 ,\
251+ metadata = False , floating_time_interval = 0 ):
252+
253+ """
254+ Calls the GetKey method in Web API 3 and returns a tuple containing
255+ (LicenseKey, Message). If an error occurs, LicenseKey will be None. If
256+ everything went well, no message will be returned.
257+
258+ More docs: https://app.cryptolens.io/docs/api/v3/GetKey
259+ """
260+
261+ response = Response ("" ,"" ,0 ,"" )
262+
263+ try :
264+ response = Response .from_string (HelperMethods .send_request ("key/getkey" , {"token" :token ,\
265+ "ProductId" :product_id ,\
266+ "key" :key ,\
267+ "FieldsToReturn" :fields_to_return ,\
268+ "metadata" :metadata ,\
269+ "FloatingTimeInterval" : floating_time_interval ,\
270+ "Sign" :"True" ,\
271+ "SignMethod" :1 }))
272+ except Exception :
273+ return (None , "Could not contact the server." )
274+
275+ pubkey = RSAPublicKey .from_string (rsa_pub_key )
276+
277+ if response .result == 1 :
278+ return (None , response .message )
279+ else :
280+ try :
281+ if HelperMethods .verify_signature (response , pubkey ):
282+ return (LicenseKey .from_response (response ), response .message )
283+ else :
284+ return (None , "The signature check failed." )
285+ except Exception :
286+ return (None , "The signature check failed." )
287+
249288 @staticmethod
250289 def create_trial_key (token , product_id , machine_code ):
251290 """
0 commit comments