Authentication
import requests as rq
import json
'''
Returns True or False based on the validity of the token
'''
def account_auth(token):
response = {
200: True,
403: False
}
HOST = "https://industrial.api.ubidots.com"
PATH = "/api/v1.6/user_check/"
PARAMETERS = "?token={}".format(token)
URL = "{}{}{}".format(HOST, PATH, PARAMETERS)
r = rq.get(URL)
code = r.status_code
return response[code]
def main(args):
token = args.get("token", None)
if token is None:
return {"ERROR": "Missing token"}
valid = account_auth(token)
if valid is not True:
return {"ERROR": "Token not valid"}Last updated
Was this helpful?