Skip to content

Instantly share code, notes, and snippets.

@micheleberardi
Created October 10, 2019 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micheleberardi/b1715f5c4d5eff4f8f354cf1f3d55930 to your computer and use it in GitHub Desktop.
Save micheleberardi/b1715f5c4d5eff4f8f354cf1f3d55930 to your computer and use it in GitHub Desktop.
simple clss
import requests
class Authorization:
def __init__(self, username, password, company_uid):
self.username = username
self.password = password
self.company_uid = company_uid
def token(self):
url = "https://api.domain.com/3.0/login/?username=" + self.username + "&password=" + self.password + "&company_uid=" + self.company_uid + ""
try:
response = requests.get(url)
if response.ok:
result = response.json()
token = result["data"][0]["token"]
return token
except:
print("SOMETHING WRONG HERE ")
'''
Example How use the Class
from test_slack import Authorization
authorization = Authorization(username="support@domain.com",password="ccb0eea8a706c4c34a16891f84e7b",company_uid="f5b06df5715ad43")
token = authorization.token()
print (token)
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment