'Obtain a bearer token.'

def _get_access_token(self, website):

    bearer_token_cred = ('%s:%s' % (website.twitter_api_key, website.twitter_api_secret))
    encoded_cred = base64.b64encode(bearer_token_cred)
    request = Request(REQUEST_TOKEN_URL)
    request.add_header('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8')
    request.add_header('Authorization', ('Basic    %s' % encoded_cred))
    request.add_data('grant_type=client_credentials')
    data = json.load(urlopen(request, timeout=URLOPEN_TIMEOUT))
    access_token = data['access_token']
    return access_token
