DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

Each guest token should be associated with an individual
user of an application. The guest’s activity within Webex
Teams, such as message activity or call history, will
persist, just as it would for a regular Webex Teams user.
While guest users can interact with regular Webex Teams
users, they are not allowed to interact with other guests.
Example 10-7 shows a Python code snippet that creates a
JWT token from the guest issuer ID and secret and
passes it in the authentication headers. It is then possible
to use any of the APIs to interact with other users in the
system.


Example 10-7 Python Code to Generate a JWT Token
for a Guest Issuer


Click here to view code image


""" Generate JWT """
import base64
import time
import math
import jwt
EXPIRATION = math.floor(time.time()) + 3600 # 1
hour from now
PAYLOAD = {
"sub": "devASC",
"name": "devASC-guest",
"iss": "GUEST_ISSUER_ID",
"exp": EXPIRATION
}
SECRET = base64.b64decode('GUEST_ISSUE_SECRET')
TOKEN = jwt.encode(PAYLOAD, SECRET)
print(TOKEN.decode('utf-8'))
HEADERS = {
'Authorization': 'Bearer ' +
TOKEN.decode('utf-8')
}
Free download pdf