import json import requests stagingUrl = "https://us-west-2.staging.shared.aws.tidbcloud.com" nightlyUrl = "https://us-west-2.nightly.shared.aws.tidbcloud.com" stagingTokenBody = { "auth0_client_secret": "7Mscj-t2WywzEW0MfkZxhOjbuSH9Idv4KiHOMacnCiN3AuiYYOeYX4Sh3ysEcLIY", "auth0_client_id": "cDDAEOmwqb53IL1tgoSf4JaB4chVTviY", "auth0_domain": "tidb-staging.us.auth0.com", "email": "dengshuan@pingcap.com" } devTokenBody = { "auth0_client_secret": "IAmmRVJ1nRb8EkldjuWGZZsaEybpG75maUi7DD9HnkyWr946D41FdqO6B_BBmVlc", "auth0_client_id": "2N1OzujS8JMz5IZF2uico2kBIXquVrwA", "auth0_domain": "tidb-dev.us.auth0.com", "email": "dengshuan@pingcap.com" } def fetchDBaaSToken(env, email): print("fetch token from {}".format(email) ) if env == 'nightly': devTokenBody['email'] = email r = requests.post( nightlyUrl + "/api/v1/test-token", json = devTokenBody ) print( r.text) tokenResponse = json.loads(r.text) tk = "" if "token" in tokenResponse: tk = tokenResponse['token'] return "Bearer " + tokenResponse['token'] elif env == 'staging': stagingTokenBody['email'] = email r = requests.post( stagingUrl + "/api/v1/test-token", json = stagingTokenBody ) print( r.text) tokenResponse = json.loads(r.text) tk = "" if "token" in tokenResponse: tk = tokenResponse['token'] return "Bearer " + tokenResponse['token'] if "__main__" == __name__: token = fetchDBaaSToken('nightly', 'dbaas_test8@163.com') print(token) # token = fetchDBaaSToken('staging', 'dbaas_test8@163.com') print(token)