Qiskit/qiskit-ibm-provider

API token issue

jiejiangrx opened this issue · 4 comments

Information

  • qiskit-ibm-provider version:
  • 0.18.1
  • Python version:
  • 3.8.3
  • Operating system:
  • windows 10

What is the current behavior?

import qiskit
from qiskit import IBMQ
IBMQ.delete_account()
IBMQ.save_account('my_API_token', overwrite=True)
provider = IBMQ.load_account()

I installed qiskit 0.33.0 on my laptop. I used jupter notebook under anaconda.
When I run the above codes, I got error of
"RequestsApiError: '401 Client Error: Unauthorized for url: https://auth.quantum-computing.ibm.com/api/users/loginWithToken. Login failed., Error code: 3446.'"

Steps to reproduce the problem

I regenerated and copied the API token from my IBM quantum dashboard.
I repeated the above codes many times. I always got the same error.

What is the expected behavior?

It should allow to access IBM account.

Suggested solutions

I attached the detailed error messages. Is this issue due to deactivation of my IBM account? or an
issue not able to pass the token to the account port?

APIerror.txt

jwoehr commented

This is not the correct way to use the new qiskit-ibm-provider.
Please see https://cloud.ibm.com/docs/quantum-computing?topic=quantum-computing-migrate-setup

julenl commented

I am having the exact same error, regardless of the way I try to access it.

  • qiskit-ibm-runtime version: 0.11.1
  • requests version: 2.31.0
  • Python version: 3.10.6
  • OS: Ubuntu

One of the snippets I tried, from the link provided by @jwoehr:

    from qiskit_ibm_runtime import QiskitRuntimeService
    my_token = "mylongtoken"
    QiskitRuntimeService.save_account(channel="ibm_quantum", token=my_token, overwrite=True)
    QiskitRuntimeService.saved_accounts()
    # Shows the stored credentials
    QiskitRuntimeService(channel="ibm_quantum")

Produces the exact same error as the one from @jiejiangrx.

In all cases (IBMQ, IBMProvider, QiskitRuntimeService) it ends up at the same point: the server refuses to authorize.
This can be more easily reproduced by:

    import requests
    url = "https://auth.quantum-computing.ibm.com/api/users/loginWithToken"
    r = requests.post(url, json={"apiToken": my_token})
    print(r.text)
    '{"error":{"statusCode":401,"name":"LOGIN_FAILED","message":"Login failed.","code":3446}}'

I tried those, first with my old token, which used to work fine some weeks ago (with IBMQ) and with a few freshly generated tokens.

It seems to be a problem with the auth on the server. Maybe the clients are using a wrong endpoint URL by default?

kt474 commented

Hi @julenl can you try refreshing your api token https://quantum-computing.ibm.com/ and try initializing the provider again

from qiskit_ibm_provider import IBMProvider

IBMProvider.save_account(token='MY_API_TOKEN')
provider = IBMProvider()

julenl commented

Thanks @kt474!
Your suggestion worked perfectly.

Wow... that was confusing.
I was generating my tokens on https://de.quantum-computing.ibm.com/ and assumed that the authentication was centralized, but it's not!
I guess I can't connect with the token of the German site because my ticket starts actually tomorrow.