Created
October 10, 2019 15:45
-
-
Save micheleberardi/b1715f5c4d5eff4f8f354cf1f3d55930 to your computer and use it in GitHub Desktop.
simple clss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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