Skip to content

Commit 7bd55fd

Browse files
3.2.0
## Enhancements - Updated demo with new UI and features. - Unit tests. - Bug fixes. - Updated some existing API's: Get Roles by UID: moved to role class Assign Roles by UID: moved role class One Touch Login: moved to authentication.login class Get Backup Code by Access Token: moved to authentication.TwoFactor class Reset Backup Code by Access Token: moved to authentication.TwoFactor class Get Backup Code by UID: moved to account.TwoFactor class Reset Backup Code by UID: moved to account.TwoFactor class - New V2 API's: Auth Privacy Policy Accept Auth Send Welcome Email Auth Verify Email by OTP Auth Delete Account Account Email Delete Phone Login Using OTP Phone Send OTP Remove Phone ID by Access Token 2FA Validate Google Auth Code 2FA Validate OTP Validate Backup Code Update MFA by Access Token Update MFA Setting One Touch Verify OTP by Email Get Active Session Details Access Token via Vkontakte Token Access Token via Google Token Refresh User Profile Refresh Token Delete All Records by Datasource
1 parent 40e2028 commit 7bd55fd

File tree

115 files changed

+5535
-3003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+5535
-3003
lines changed

CHANGELOG.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# LoginRadius Python SDK Change Log
22

3+
# Version 3.2.0
4+
## Enhancements
5+
- Updated demo with new UI and features.
6+
- Unit tests.
7+
- Bug fixes.
8+
- Updated some existing API's:
9+
Get Roles by UID: moved to role class
10+
Assign Roles by UID: moved role class
11+
One Touch Login: moved to authentication.login class
12+
Get Backup Code by Access Token: moved to authentication.TwoFactor class
13+
Reset Backup Code by Access Token: moved to authentication.TwoFactor class
14+
Get Backup Code by UID: moved to account.TwoFactor class
15+
Reset Backup Code by UID: moved to account.TwoFactor class
16+
- New V2 API's:
17+
Auth Privacy Policy Accept
18+
Auth Send Welcome Email
19+
Auth Verify Email by OTP
20+
Auth Delete Account
21+
Account Email Delete
22+
Phone Login Using OTP
23+
Phone Send OTP
24+
Remove Phone ID by Access Token
25+
2FA Validate Google Auth Code
26+
2FA Validate OTP
27+
Validate Backup Code
28+
Update MFA by Access Token
29+
Update MFA Setting
30+
One Touch Verify OTP by Email
31+
Get Active Session Details
32+
Access Token via Vkontakte Token
33+
Access Token via Google Token
34+
Refresh User Profile
35+
Refresh Token
36+
Delete All Records by Datasource
337

438
# Version 3.1.1
539
## Bug Fixed
File renamed without changes.

example/cgi/LoginRadius/__init__.py renamed to demo/LoginRadius/__init__.py

Lines changed: 103 additions & 106 deletions
Large diffs are not rendered by default.
File renamed without changes.

example/cgi/LoginRadius/sdk/accessToken.py renamed to demo/LoginRadius/sdk/accessToken.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
__copyright__ = "Copyright 2017-2018, LoginRadius"
2121
__email__ = "[email protected]"
2222
__status__ = "Production"
23-
__version__ = "3.1.0"
23+
__version__ = "3.2.0"
2424

2525

2626
tokenEndpoint = "/api/v2/access_token"
@@ -34,39 +34,57 @@ def __init__(self, lr_object):
3434
self._lr_object = lr_object
3535

3636
def exchange(self, token):
37-
"""The Access Token API is used to get the LoginRadius access token after authentication. It will be valid for the specific duration of time specified in the response"""
37+
# Access Token (GET)
3838
payload = {'token': token, 'secret': self._lr_object._get_api_secret()}
3939
url = self._lr_object.SECURE_API_URL + tokenEndpoint
4040
return self._lr_object._get_json(url, payload)
4141

4242
def validate(self, access_token):
43-
"""Token Validate( GET )"""
43+
# Token Validate (GET)
4444
payload = {'key': self._lr_object._get_api_key(), 'secret': self._lr_object._get_api_secret(),'access_token':access_token}
4545
url = self._lr_object.SECURE_API_URL + tokenEndpoint + "/Validate"
4646
return self._lr_object._get_json(url, payload)
4747

4848
def invalidate(self, access_token):
49-
"""Token Validate( GET )"""
49+
# Access Token Invalidate (GET)
5050
payload = {'key': self._lr_object._get_api_key(), 'secret': self._lr_object._get_api_secret(),'access_token':access_token}
5151
url = self._lr_object.SECURE_API_URL + tokenEndpoint + "/invalidate"
5252
return self._lr_object._get_json(url, payload)
5353

54-
def refresh(self, access_token):
55-
"""Token Validate( GET )"""
56-
payload = {'key': self._lr_object._get_api_key(), 'secret': self._lr_object._get_api_secret(),'access_token':access_token}
54+
def activeSessionDetails(self, access_token):
55+
# Get Active Session Details (GET)
56+
payload = {'key': self._lr_object._get_api_key(), 'secret': self._lr_object._get_api_secret(),'token':access_token}
57+
url = self._lr_object.SECURE_API_URL + tokenEndpoint + "/activesession"
58+
return self._lr_object._get_json(url, payload)
59+
60+
def refresh(self, access_token, expiresIn=''):
61+
# Refresh Token (GET)
62+
payload = {'key': self._lr_object._get_api_key(), 'secret': self._lr_object._get_api_secret(),'access_token':access_token, 'expiresIn':expiresIn}
5763
url = self._lr_object.SECURE_API_URL + tokenEndpoint + "/refresh"
5864
return self._lr_object._get_json(url, payload)
5965

6066
def getFacebookToken(self, fb_access_token):
61-
"""Token Validate( GET )"""
67+
# Access Token via Facebook Token (GET)
6268
payload = {'key': self._lr_object._get_api_key(),'fb_access_token':fb_access_token}
6369
url = self._lr_object.SECURE_API_URL + tokenEndpoint + "/facebook"
6470
return self._lr_object._get_json(url, payload)
6571

6672
def getTwitterToken(self, tw_access_token, tw_token_secret):
67-
"""Token Validate( GET )"""
73+
# Access Token via Twitter Token (GET)
6874
payload = {'key': self._lr_object._get_api_key(),'tw_access_token':tw_access_token, 'tw_token_secret':tw_token_secret}
6975
url = self._lr_object.SECURE_API_URL + tokenEndpoint + "/twitter"
7076
return self._lr_object._get_json(url, payload)
77+
78+
def getVkontakteToken(self, vk_access_token):
79+
# Access Token via Vkontakte Token (GET)
80+
payload = {'key': self._lr_object._get_api_key(),'vk_access_token':vk_access_token}
81+
url = self._lr_object.SECURE_API_URL + tokenEndpoint + "/vkontakte"
82+
return self._lr_object._get_json(url, payload)
83+
84+
def getGoogleToken(self, id_token):
85+
# Access Token via Google JWT (GET)
86+
payload = {'key': self._lr_object._get_api_key(),'id_token':id_token}
87+
url = self._lr_object.SECURE_API_URL + tokenEndpoint + "/googlejwt"
88+
return self._lr_object._get_json(url, payload)
7189

7290

example/cgi/LoginRadius/sdk/account.py renamed to demo/LoginRadius/sdk/account.py

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
__copyright__ = "Copyright 2017-2018, LoginRadius"
2121
__email__ = "[email protected]"
2222
__status__ = "Production"
23-
__version__ = "3.1.0"
23+
__version__ = "3.2.0"
2424

2525

2626
accountEndpoint = "identity/v2/manage/account/"
@@ -37,45 +37,47 @@ def __init__(self, lr_object):
3737
self._lr_object = lr_object
3838

3939
def create(self, payload, fields = '*'):
40-
"""Create Account( POST )"""
40+
# Account Create (POST)
4141
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
4242
params = 'fields='+fields
4343
url = self._lr_object.SECURE_API_URL + accountEndpoint + "?" + params
4444
return self._lr_object._post_json(url, payload, headers)
4545

4646
def update(self, uid, payload, isNullSupport = False, fields = '*'):
47-
"""Update Account( POST )"""
47+
# Account Update (PUT)
4848
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
49-
params = 'nullsupport=' + isNullSupport + "&fields=" +fields
49+
params = 'nullsupport=' + str(isNullSupport) + "&fields=" +fields
5050
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "?" + params
5151
return self._lr_object._put_json(url, payload, headers)
5252

5353
def remove(self, uid):
54-
"""Account Delete( DELETE )"""
54+
# Account Delete (DEL)
5555
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
5656
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid
5757
return self._lr_object._delete_json(url, {}, headers)
5858

5959
def generateSott(self, timediff = '10'):
60-
"""Account generate sott( GET )"""
60+
# Generate SOTT (GET)
6161
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
6262
params = 'timedifference='+timediff
6363
url = self._lr_object.SECURE_API_URL + accountEndpoint + "sott"+"?" + params
6464
return self._lr_object._get_json(url, {}, headers)
6565

6666
def setPassword(self, uid, password):
67-
"""Account Set Password( PUT )"""
67+
# Account Set Password (PUT)
6868
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
6969
payload = {"password": password}
70-
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "/password"+"?" + params
70+
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "/password"
7171
return self._lr_object._put_json(url, payload, headers)
7272

7373
def getPassword(self, uid):
74+
# Account Password (GET)
7475
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
7576
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "/password"
7677
return self._lr_object._get_json(url, {}, headers)
7778

7879
def invalidateVerificationEmail(self, uid, verificationUrl = '', emailTemplate = ''):
80+
# Account Invalidate Verification Email (PUT)
7981
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
8082
params = 'verificationUrl=' + verificationUrl + "&emailTemplate=" +emailTemplate
8183
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "/invalidateemail"+"?" + params
@@ -99,62 +101,52 @@ def getDeletedAccountByUid(self, uid):
99101
url = self._lr_object.SECURE_API_URL + archivedEndpoint
100102
return self._lr_object._get_json(url, payload, headers)
101103

102-
def assignRole(self, uid, payload):
103-
"""Put Assign Role( PUT )"""
104-
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
105-
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "/role"
106-
return self._lr_object._put_json(url, payload, headers)
107-
108-
def getRoleByUid(self, uid):
109-
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
110-
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "/role"
111-
return self._lr_object._get_json(url, {}, headers)
112-
113104
def updateSecurityQuestion(self, uid, payload):
105+
# Account Update Security Question Configuration (PUT)
114106
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
115107
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid
116108
return self._lr_object._put_json(url, payload, headers)
117109

118110
def getForgotPasswordToken(self, email):
111+
# Forgot Password Token (POST)
119112
payload = {"email":email}
120113
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
121114
url = self._lr_object.SECURE_API_URL + accountEndpoint + "forgot/token"
122115
return self._lr_object._post_json(url, payload, headers)
123116

124117
def getEmailVerificationToken(self, email):
118+
# Email Verification Token (POST)
125119
payload = {"email":email}
126120
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
127121
url = self._lr_object.SECURE_API_URL + accountEndpoint + "verify/token"
128122
return self._lr_object._post_json(url, payload, headers)
129123

130124
def getAccessToken(self, uid):
125+
# Access Token based on UID or User impersonation API (GET)
131126
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
132-
payload = {"uid":uid}
133-
url = self._lr_object.SECURE_API_URL + accountEndpoint + "access_token"
134-
return self._lr_object._get_json(url, payload, headers)
127+
params = 'uid=' + uid
128+
url = self._lr_object.SECURE_API_URL + accountEndpoint + "access_token" + "?" + params
129+
return self._lr_object._get_json(url, {}, headers)
135130

136131
def getIdentities(self, email, fields= '*'):
132+
# Account Identities by Email (GET)
137133
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
138134
params = 'email=' + email + "&fields=" +fields
139135
url = self._lr_object.SECURE_API_URL + accountEndpoint + "identities" + "?" + params
140136
return self._lr_object._get_json(url, {}, headers)
141137

142138
def resetPhoneIdVerification(self, uid):
139+
# Reset phone ID verification (PUT)
143140
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
144141
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "/invalidatephone"
145142
return self._lr_object._put_json(url, {}, headers)
146143

147-
def getBackupCodeByUid(self, uid):
148-
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
149-
payload = {"uid":uid}
150-
url = self._lr_object.SECURE_API_URL + accountEndpoint + "2fa/backupcode"
151-
return self._lr_object._get_json(url, payload, headers)
152-
153-
def resetBackupCodeByUid(self, uid):
154-
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
155-
payload = {"uid":uid}
156-
url = self._lr_object.SECURE_API_URL + accountEndpoint + "2fa/backupcode/reset"
157-
return self._lr_object._get_json(url, payload, headers)
144+
def removeEmail(self, uid, email):
145+
# Account Email Delete (DEL)
146+
payload = {'email':email}
147+
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
148+
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + '/email'
149+
return self._lr_object._delete_json(url, payload, headers)
158150

159151

160152
class Profile:
@@ -163,24 +155,28 @@ def __init__(self, lr_object):
163155
self._lr_object = lr_object
164156

165157
def getByEmail(self, email, fields = '*'):
158+
# Account Profiles by Email (GET)
166159
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
167160
params = 'email=' + email + "&fields=" +fields
168161
url = self._lr_object.SECURE_API_URL + accountEndpoint + "?" + params
169162
return self._lr_object._get_json(url, {}, headers)
170163

171164
def getByUsername(self, username, fields = '*'):
165+
# Account Profiles by Username (GET)
172166
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
173167
params = 'username=' + username + "&fields=" +fields
174168
url = self._lr_object.SECURE_API_URL + accountEndpoint + "?" + params
175169
return self._lr_object._get_json(url, {}, headers)
176170

177171
def getByPhone(self, phone, fields = '*'):
172+
# Account Profile by Phone ID (GET)
178173
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
179174
params = 'phone=' + phone + "&fields=" +fields
180175
url = self._lr_object.SECURE_API_URL + accountEndpoint + "?" + params
181176
return self._lr_object._get_json(url, {}, headers)
182177

183178
def getByUid(self, uid, fields = '*'):
179+
# Account Profiles by UID (GET)
184180
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
185181
params = "fields=" +fields
186182
url = self._lr_object.SECURE_API_URL + accountEndpoint + uid + "?" + params
@@ -192,38 +188,61 @@ def __init__(self, lr_object):
192188
self._lr_object = lr_object
193189

194190
def removeAuthByUid(self, uid, authenticator):
191+
# MFA Reset Google Authenticator By UID (DEL) & MFA Reset SMS Authenticator By UID (DEL)
195192
payload = {}
196193
payload[authenticator] = True
197194
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
198195
params = 'uid='+uid
199196
url = self._lr_object.SECURE_API_URL + accountEndpoint + "2FA/authenticator?" + params
200197
return self._lr_object._delete_json(url, payload, headers)
201198

199+
def getBackupCodeByUid(self, uid):
200+
# MFA Backup Code by UID (GET)
201+
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
202+
payload = {"uid":uid}
203+
url = self._lr_object.SECURE_API_URL + accountEndpoint + "2fa/backupcode"
204+
return self._lr_object._get_json(url, payload, headers)
205+
206+
def resetBackupCodeByUid(self, uid):
207+
# MFA Reset Backup Code by UID (GET)
208+
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
209+
payload = {"uid":uid}
210+
url = self._lr_object.SECURE_API_URL + accountEndpoint + "2fa/backupcode/reset"
211+
return self._lr_object._get_json(url, payload, headers)
212+
202213
class RegistrationData:
203214

204215
def __init__(self, lr_object):
205216
self._lr_object = lr_object
206217

207218
def addRegistrationData(self, payload):
219+
# Add Registration Data (POST)
208220
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
209221
url = self._lr_object.SECURE_API_URL + registrationDataEndpoint + "registrationdata"
210222
return self._lr_object._post_json(url, payload, headers)
211223

212224
def getRegistrationDataServer(self, datasourcetype, parentid='', skip = '', limit = ''):
225+
# Get Registration Data (GET)
213226
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
214227
params = 'parentid='+ parentid+'&skip='+ skip+'&limit='+ limit
215228
url = self._lr_object.SECURE_API_URL + registrationDataEndpoint + "registrationdata/" + datasourcetype + "?" + params
216229
return self._lr_object._get_json(url, {}, headers)
217230

218231
def updateRegistrationData(self, recordid, payload):
219-
"""Update Registration Data( PUT )"""
232+
# Update Registration Data (PUT)
220233
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
221234
url = self._lr_object.SECURE_API_URL + registrationDataEndpoint + "registrationdata/" + recordid
222235
return self._lr_object._put_json(url, payload, headers)
223236

224237
def deleteRegistrationData(self, recordid):
225-
"""Delete Registration Data( delete )"""
238+
# Delete Registration Data (DEL)
226239
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
227240
url = self._lr_object.SECURE_API_URL + registrationDataEndpoint + "registrationdata/" + recordid
228241
return self._lr_object._delete_json(url, {}, headers)
242+
243+
def deleteAllRecordsByDatasource(self, datasourcetype):
244+
# Delete All Records by Datasource (DEL)
245+
headers = {'apikey': self._lr_object._get_api_key(), 'apisecret': self._lr_object._get_api_secret()}
246+
url = self._lr_object.SECURE_API_URL + registrationDataEndpoint + "registrationdata/type/" + datasourcetype
247+
return self._lr_object._delete_json(url, {}, headers)
229248

0 commit comments

Comments
 (0)