Пример #1
0
def refresh_auth(provider):
    logger.debug('Refreshing auth')
    post_data = {'refreshToken': config.disney_token.refresh_token}
    resp = global_session.post(url_for_provider(REFRESH_AUTH_URL, provider),
                               headers={
                                   'Content-Type': 'application/json',
                               },
                               json=post_data)
    config.set_disney_id_token(resp.json()['data']['token']['id_token'])
Пример #2
0
def get_login_id_token(username, password, provider):
    if config.disney_id_token is None or not config.disney_id_token.is_valid():
        logger.debug('Getting ID Token')
        resp = global_session.post(
            url_for_provider(LOGIN_URL, provider),
            headers={'Authorization': 'APIKEY %s' % get_api_key(provider)},
            json={
                'loginValue': username,
                'password': password
            })
        config.set_disney_id_token(resp.json()['data']['token']['id_token'])
    return config.disney_id_token.token
Пример #3
0
def execute_method(endpoint, access_token='', json_body=None, data=None):
    logger.debug('Executing endpoint %s' % endpoint['href'])
    http_headers = {}
    for i, (header, value) in enumerate(endpoint['headers'].items()):
        http_headers[header] = fill_in_template(value, access_token)
    resp = None
    if endpoint['method'] == 'POST':
        resp = global_session.post(endpoint['href'],
                                   headers=http_headers,
                                   json=json_body,
                                   data=data)
    elif endpoint['method'] == 'GET':
        resp = global_session.get(endpoint['href'], headers=http_headers)
    return resp
Пример #4
0
def get_license_plate(provider):
    logger.debug('Getting license plate')
    post_data = {
        'content': {
            'adId': uuid.uuid1().hex,
            'correlation-id': uuid.uuid1().hex,
            'deviceId': uuid.uuid1().hex,
            'deviceType': 'ANDTV',
            'entitlementPath': 'login',
            'entitlements': [],
        },
        'ttl': 0
    }
    resp = global_session.post(url_for_provider(LICENSE_PLATE_URL, provider),
                               headers={
                                   'Authorization':
                                   'APIKEY %s' % get_api_key(provider),
                                   'Content-Type':
                                   'application/json',
                               },
                               json=post_data)
    return post_data, resp.json()
Пример #5
0
def get_api_key(provider):
    logger.debug('Getting API Key')
    resp = global_session.post(url_for_provider(API_KEY_URL, provider))
    return resp.headers.get('api-key')