Created
May 30, 2019 14:40
-
-
Save giacomoferretti/e2131c2c54de2b497d3e8707e80be296 to your computer and use it in GitHub Desktop.
mcdapi - Generate Coupon
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
def generate_coupon(id): | |
# Generate config | |
android_id = coupon.get_random_device_id() | |
vmob_uid = coupon.generate_vmob_uid(android_id) | |
username = coupon.generate_username(android_id) | |
password = coupon.generate_password(android_id) | |
plexurek = coupon.generate_plexure_api_key(vmob_uid) | |
headers = coupon.strip_unnecessary_headers(coupon.get_random_headers(vmob_uid, plexurek)) | |
r = requests.request(endpoints.DEVICE_REGISTRATION['method'], endpoints.DEVICE_REGISTRATION['url'], | |
data=endpoints.DEVICE_REGISTRATION['body'].format(username, password), headers=headers) | |
if r.status_code == 200: | |
print('Successfully got a token.') | |
js = json.loads(r.content) | |
ACCESS_TOKEN = js['access_token'] | |
TOKEN_TYPE = js['token_type'] | |
print('TOKEN: ' + ACCESS_TOKEN) | |
headers['Authorization'] = 'bearer {}'.format(ACCESS_TOKEN) | |
r = requests.post(endpoints.REDEEM_OFFER['url'], data=endpoints.REDEEM_OFFER['body'].format(id, id), | |
headers=headers) | |
js = json.loads(r.content.decode()) | |
return js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment