Beispiel #1
0
    def set_basic_authentication(self, email: str, password: str, qi_url: str = QI_URL) -> None:
        """
        Set up basic authentication for Quantum Inspire.

        Args:
            email: A valid email address.
            password: Password for the account.
            qi_url: URL that points to quantum-inspire api. Default value: 'https://api.quantum-inspire.com'.
        """
        authentication = get_basic_authentication(email, password)
        self.set_authentication(authentication, qi_url)
Beispiel #2
0
def get_authentication_alt():
    """ Gets the authentication for connecting to the Quantum Inspire API."""
    token = load_account()
    if token is not None:
        return get_token_authentication(token)
    else:
        print('Enter email:')
        email = input()
        print('Enter password')
        password = getpass()
        return get_basic_authentication(email, password)
def get_authentication(qi_email=None, qi_password=None, token=None):
    """ Gets the authentication for connecting to the Quantum Inspire API."""
    if token is not None:
        return get_token_authentication(token)
    else:
        if qi_email is None or qi_password is None:
            print('Enter email')
            email = input()
            print('Enter password')
            password = getpass()
        else:
            email, password = qi_email, qi_password
        return get_basic_authentication(email, password)
Beispiel #4
0
def get_authentication():
    """ Gets the authentication for connecting to the Quantum Inspire API."""
    token = load_token()
    if token is not None:
        return get_token_authentication(token)
    else:
        if QI_EMAIL is None or QI_PASSWORD is None:
            print('Enter email:')
            email = input()
            print('Enter password')
            password = getpass()
        else:
            email, password = QI_EMAIL, QI_PASSWORD
        return get_basic_authentication(email, password)
Beispiel #5
0
def get_authentication(B):
    if B == 'QI':
        """ Gets the authentication for connecting to the Quantum Inspire API."""
        token = load_account()
        if token is not None:
            return get_token_authentication(token)
        else:
            if QI_EMAIL is None or QI_PASSWORD is None:
                print('Enter email:')
                email = input()
                print('Enter password')
                password = getpass()
            else:
                email, password = QI_EMAIL, QI_PASSWORD
            return get_basic_authentication(email, password)
    elif B == 'IBMQ':
        print('Enter IBMQ token:')
        ibmq_token = input()
        return IBMQ.enable_account(ibmq_token)
Beispiel #6
0
 def test_get_basic_authentication(self):
     email = '*****@*****.**'
     secret_password = '******'
     auth = get_basic_authentication(email, secret_password)
     auth_expected = BasicAuthentication(email, secret_password)
     self.assertEqual(auth, auth_expected)