#!/usr/bin/env python import requests from constants import * auth = requests.auth.HTTPBasicAuth(client_id, client_secret) data = { 'grant_type': 'password', 'username': username, 'password': password, 'device_id': 5, 'duration': 'permanent', } headers = {'User-Agent': user_agent} r = requests.post('https://reddit.local:8001/api/v1/access_token', auth=auth, data=data, headers=headers, verify=False) print r print r.json()