def test_create_client_with_invalid_arguments(self):
        with pytest.raises(ValueError):
            MixedRealityStsClient(
                account_id=None,
                account_domain=self.account_domain,
                credential=self.key_credential)

        with pytest.raises(ValueError):
            MixedRealityStsClient(
                account_id=self.account_id,
                account_domain=None,
                credential=self.key_credential)

        with pytest.raises(ValueError):
            MixedRealityStsClient(
                account_id=self.account_id,
                account_domain=self.account_domain,
                credential=None)

        with pytest.raises(ValueError):
            MixedRealityStsClient(
                account_id=self.account_id,
                account_domain=self.account_domain,
                credential=self.key_credential,
                custom_endpoint_url="#")
    def get_token(self):
        # [START get_token]
        from azure.mixedreality.authentication import MixedRealityStsClient
        client = MixedRealityStsClient(self.account_id, self.account_domain, self.key_credential)
        access_token = client.get_token()
        # [END get_token]

        print("token retrieved: " + access_token.token)
 def __init__(self, account_id, account_domain, endpoint_url, credential, **kwargs):
     # type: (str, str, str, TokenCredential, Any) -> None
     self.stsClient = MixedRealityStsClient(
         account_id=account_id,
         account_domain=account_domain,
         endpoint_url=endpoint_url,
         credential=credential,
         **kwargs)
    def test_get_token(self):
        client = MixedRealityStsClient(
            account_id=self.account_id,
            account_domain=self.account_domain,
            credential=self.key_credential)

        token = client.get_token()

        assert token is not None
        assert token.token is not None
        assert token.expires_on is not None
    def create_client(self):
        # [START create_client]
        from azure.mixedreality.authentication import MixedRealityStsClient
        client = MixedRealityStsClient(self.account_id, self.account_domain, self.key_credential)
        # [END create_client]

        print("client created")
    def test_create_client(self):
        client = MixedRealityStsClient(
            account_id=self.account_id,
            account_domain=self.account_domain,
            credential=self.key_credential)

        assert client is not None
    def test_create_client_with_credential(self):
        token_credential = MixedRealityAccountKeyCredential(self.account_id, self.key_credential)
        client = MixedRealityStsClient(
            account_id=self.account_id,
            account_domain=self.account_domain,
            credential=token_credential)

        assert client._credential == token_credential
    def test_create_client_custom_with_endpoint(self):
        custom_endpoint_url = "https://my.custom.endpoint"
        client = MixedRealityStsClient(
            account_id=self.account_id,
            account_domain=self.account_domain,
            credential=self.key_credential,
            custom_endpoint_url=custom_endpoint_url)

        assert client._endpoint_url == custom_endpoint_url
class MixedRealityTokenCredential(object):
    """ Represents a token credential that can be used to access a Mixed Reality service.
    This implements the TokenCredential protocol.

    :param str account_id: The Mixed Reality service account identifier.
    :param str endpoint_url: The Mixed Reality STS service endpoint.
    :param TokenCredential credential: The credential used to access the Mixed Reality service.
    """

    def __init__(self, account_id, account_domain, endpoint_url, credential, **kwargs):
        # type: (str, str, str, TokenCredential, Any) -> None
        self.stsClient = MixedRealityStsClient(
            account_id=account_id,
            account_domain=account_domain,
            endpoint_url=endpoint_url,
            credential=credential,
            **kwargs)

    def get_token(self, *scopes, **kwargs): #pylint: disable=unused-argument
        # type: (*str, **Any) -> AccessToken
        return self.stsClient.get_token(**kwargs)