-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvline.py
More file actions
35 lines (31 loc) · 958 Bytes
/
vline.py
File metadata and controls
35 lines (31 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import jwt
import time
# replace with values from your service settings
# see: https://vline.com/developer/docs/authentication
API_SECRET = 'ThCMF2db7bGdfWAZUbGnemPPQt5wZopKBY46eryke0k'
SERVICE_ID = 'vhelp'
SESSION_EXPIRATION_TIME = 48 * 60 * 60 # 2 days in seconds
def create_auth_token(userId):
# jwt payload
payload = {
"sub" : SERVICE_ID + ":" + str(userId),
"iss" : SERVICE_ID,
"exp" : time.time() + SESSION_EXPIRATION_TIME
}
# encode and sign token
api_secret_key = jwt.base64url_decode(API_SECRET)
return jwt.encode(payload, api_secret_key);
def create_user_profile(user):
if user.last_name or user.first_name:
display_name = user.get_full_name()
else:
display_name = user.get_username()
return {
"id": user.id,
"displayName": display_name
}
def create_guest_profile(userId):
return {
"id": userId,
"displayName": "Customer"
}