OTP with Python

Generate an OTP Token (One Time Password) with Python


Example in Python:

import urllib2

afilnet_class="otp"
afilnet_method="generateotp"
afilnet_user="user"
afilnet_password="password"
afilnet_type="number"
afilnet_destination="34600000000"
afilnet_time="1"
afilnet_timetype="days"
afilnet_length="6"
afilnet_otpformat="all"
afilnet_output=""

# Create an URL request
sUrl = "https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&type="+afilnet_type+"&destination="+afilnet_destination+"&time="+afilnet_time+"&timetype="+afilnet_timetype+"&length="+afilnet_length+"&otpformat="+afilnet_otpformat+"&output="+afilnet_output
	
result = urllib2.urlopen(sUrl).read()



See example in:

PHP Java C Sharp Unix Ruby on rails Python Android Objective C / iPhone SQL Server Oracle Node JS Go lang Scala lang Swift


Generate an unique use password (OTP - One-Time Password)


ParameterDescriptionCompulsory / Optional
class=otpClass requested: Class to which the request is madeCompulsory
method=generateotpClass method requested: Method of the class to which the request is madeCompulsory
userUser and e-mail of your Afilnet accountCompulsory
passwordPassword of your Afilnet accountCompulsory
typeType of group (email or mobile)Compulsory
destinationMobile number or destination emailCompulsory
timeNumber of days, weeks, months or yearsOptional
timetypeType of time (Posible value: days, weeks, months o years)Optional
lengthLength of the password to generateOptional
otpformatFormat of the password to generate, if it includes all the characters, only numbers or only letters (all, numbers, letters)Optional
outputOutput format of the resultOptional

When you make requests you will receive the following fields:

  •  status
  •  result (if status=success), here you will receive the following values:
    • No additional values will be sent to you
  •  error (if status=error), here you will receive the error code

The possible error codes are listed below

CodeDescription
MISSING_USERUser or email not included
MISSING_PASSWORDPassword not included
MISSING_CLASSClass not included
MISSING_METHODMethod not included
MISSING_COMPULSORY_PARAMCompulsory parameter not included
INCORRECT_USER_PASSWORDIncorrect user or password
INCORRECT_CLASSIncorrect class
INCORRECT_METHODIncorrect method
INCORRECT_TIME_TYPEIncorrect type of time (possible values: days, weeks, months or years)
INCORRECT_TYPEIncorrect type. The type must be mobile or email
INCORRECT_FORMATERROR_INCORRECT_FORMAT
INCORRECT_OTP_FORMATERROR_INCORRECT_OTP_FORMAT
Parameters:
  • class: otp
  • method: generateotp
  • user: user
  • password: password
  • type: number
  • destination: 34600000000
  • time: 1
  • timetype: days
  • length: 6
  • otpformat: all
  • output:
Request:
https://www.afilnet.com/api/http/?class=otp&method=generateotp&user=user&password=password&type=number&destination=34600000000&time=1&timetype=days&length=6&otpformat=all&output=
IMPORTANT INFORMATION ABOUT COOKIES: If you continue to use this web we will assume that you accept the terms of use. You will find more information in our Cookies Policy. Continue