Created
January 8, 2018 06:44
-
-
Save cundi/98d22f7c1e4f882b204240cb0e2b744e to your computer and use it in GitHub Desktop.
demo for delete kandy user
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
huatang_DAK = xxx | |
huatang_DAS = xxx | |
def get_dat(dak, das): | |
""" | |
Domain access token | |
GET | |
/v1.3/domains/accessTokens{?key,domain_api_secret} | |
""" | |
url = api_host + '/v1.3/domains/accessTokens?key={0}&domain_api_secret={1}'.format(dak, das) | |
r = get(url) | |
DAT = r.json()['result']['domain_access_token'] | |
return DAT | |
def get_domain_users(dak, das): | |
""" | |
Get a list of Users for a Domain | |
""" | |
url = api_host + '/v1.3/domains/users?key={DAT}'.format(DAT=get_dat(dak, das)) | |
r = get(url) | |
resp = r.json() | |
return resp | |
def delete_domain_users(): | |
""" | |
""" | |
url = 'https://api.kandycn.com/v1.3/domains/users?key={0}&user_api_key={1}' | |
raw_users = get_domain_users(huatang_DAK, huatang_DAS) | |
users = raw_users.get('result').get('users') | |
headers = {'content-type': 'application/json'} | |
DAT = get_dat(huatang_DAK, huatang_DAS) | |
print(DAT) | |
for i in users: | |
uak = i['user_api_key'] | |
response = delete(url.format(DAT, uak), headers=headers) | |
print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment