コード例 #1
0
ファイル: data.py プロジェクト: schenedx/registrar
def get_client(host_base_url):
    """
    Returns an authenticated edX REST API client.
    """
    client = rest_client.OAuthAPIClient(host_base_url, CLIENT_ID,
                                        CLIENT_SECRET)
    client._check_auth()
    if not client.auth.token:
        raise 'No Auth Token'
    return client
コード例 #2
0
def _get_client(host_base_url):
    """
    Returns an authenticated edX REST API client.
    """
    client = rest_client.OAuthAPIClient(
        host_base_url,
        settings.BACKEND_SERVICE_EDX_OAUTH2_KEY,
        settings.BACKEND_SERVICE_EDX_OAUTH2_SECRET,
    )
    client._check_auth()  # pylint: disable=protected-access
    if not client.auth.token:  # pragma: no cover
        raise 'No Auth Token'
    return client
コード例 #3
0
    def get_fixture(self, programs, catalog_host, auth_host, client_id, client_secret):
        client = rest_client.OAuthAPIClient(
            auth_host,
            client_id,
            client_secret,
        )

        url = urljoin(
            catalog_host,
            'extensions/api/v1/program-fixture/?programs={query}'.format(
                query=','.join(programs)
            )
        )

        response = client.request('GET', url)

        if response.status_code != 200:
            raise CommandError('Unexpected response loading programs from discovery service: {code} {msg}'.format(
                code=response.status_code,
                msg=response.text,
            ))

        return response.text