From cab2eeaafbd95827a269e34a85ed2820bbbe5129 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 14 Nov 2024 14:11:53 -0500 Subject: [PATCH 1/6] test twisty --- docs/guides/setup-channel.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/guides/setup-channel.mdx b/docs/guides/setup-channel.mdx index 76f773dc88f..61ae7f5aa5b 100644 --- a/docs/guides/setup-channel.mdx +++ b/docs/guides/setup-channel.mdx @@ -23,7 +23,6 @@ Available plans: * **Premium Plan** - Run quantum circuits on the world's best QPUs using an enterprise quantum time subscription. - ### IBM Cloud IBM Cloud offers pay-as-you-go access plans. See [IBM Quantum access plans](https://www.ibm.com/quantum/access-plans) for details. @@ -85,9 +84,13 @@ Available plans: * The `channel` parameter allows you to distinguish between different account types. When initializing the account, IBM Cloud is the default account used if have saved credentials for an IBM Quantum Platform and an IBM Cloud account. - Account credentials are saved in plain text, so only do so if you are using a trusted device. + Account credentials are saved in plain text. It is recommended to use environment variables to securely manage your token. +
+Securely manage your token with environment variablesText here +
+ IBM Cloud is the default account used if you don't specify a different channel or account name. From f92740f9a3493bbb580ff64190e4b808dcd8af35 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 14 Nov 2024 15:15:11 -0500 Subject: [PATCH 2/6] add info on env variable --- docs/guides/setup-channel.mdx | 78 +++++++++++++++++++++++++++++------ 1 file changed, 66 insertions(+), 12 deletions(-) diff --git a/docs/guides/setup-channel.mdx b/docs/guides/setup-channel.mdx index 61ae7f5aa5b..638afbc819b 100644 --- a/docs/guides/setup-channel.mdx +++ b/docs/guides/setup-channel.mdx @@ -84,12 +84,37 @@ Available plans: * The `channel` parameter allows you to distinguish between different account types. When initializing the account, IBM Cloud is the default account used if have saved credentials for an IBM Quantum Platform and an IBM Cloud account. - Account credentials are saved in plain text. It is recommended to use environment variables to securely manage your token. + Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; click the following collapsible section for more information. -
-Securely manage your token with environment variablesText here -
+
+ + Securely manage your token with an environment variable + + To store sensitive information like account credentials more securely, it’s a good practice to use environment variables instead of saving them in plain text. Here’s how to modify your code to load the API token from an environment variable. + + 1. Set the environment variable: + + Set the `IQP_API_TOKEN` environment variable in your system. You can do this by adding the following line to your shell profile (for example, `.bashrc`, `.zshrc`) or by setting it directly in your terminal: + + ```bash + export IQP_API_TOKEN="" + ``` + + 2. Modify the code to retrieve the token from the environment variable + + Update your code to retrieve the token from the environment variable instead of saving it directly: + + ```python + import os + from qiskit_ibm_catalog import QiskitFunctionsCatalog + + # Gather the token from your environment + iqp_api_token = os.getenv("IQP_API_TOKEN") + + QiskitFunctionsCatalog.save_account(token=iqp_api_token) + ``` +
IBM Cloud is the default account used if you don't specify a different channel or account name. @@ -208,8 +233,7 @@ Alternatively, you can also access quantum processors with REST APIs, enabling y 1. Find your API key. From the [API keys page](https://cloud.ibm.com/iam/apikeys), view or create your API key, then copy it to a secure location so you can use it for authentication. 2. Find your Cloud Resource Name (CRN). Open the [Instances page](https://cloud.ibm.com/quantum/instances) and click your instance. In the page that opens, click the icon to copy your CRN. Save it in a secure location so you can use it for authentication. - -1. Authenticate to the service by calling `QiskitRuntimeService` with your saved credentials or with your IBM Cloud API key and CRN: +1. Authenticate to the service by calling `QiskitRuntimeService` with your saved credentials or with your IBM Cloud API key and CRN: ```python from qiskit_ibm_runtime import QiskitRuntimeService @@ -241,17 +265,47 @@ Alternatively, you can also access quantum processors with REST APIs, enabling y * Credentials are saved to `$HOME/.qiskit/qiskit-ibm.json`. Do not manually edit this file. * If you don't save your credentials, you must specify them every time you start a new session. + - Account credentials are saved in plain text, so only do so if you are using a trusted device. + Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; click the following collapsible section for more information. - 1. Test your setup. Ensure that you can connect to the service: +
+ + Securely manage your token with an environment variable + + To store sensitive information like account credentials more securely, it’s a good practice to use environment variables instead of saving them in plain text. Here’s how to modify your code to load the API token from an environment variable. - ```python - from qiskit_ibm_runtime import QiskitRuntimeService + 1. Set the environment variable: - service = QiskitRuntimeService() - ``` + Set the `IQP_API_TOKEN` environment variable in your system. You can do this by adding the following line to your shell profile (for example, `.bashrc`, `.zshrc`) or by setting it directly in your terminal: + + ```bash + export IQP_API_TOKEN="" + ``` + + 2. Modify the code to retrieve the token from the environment variable + + Update your code to retrieve the token from the environment variable instead of saving it directly: + + ```python + import os + from qiskit_ibm_catalog import QiskitFunctionsCatalog + + # Gather the token from your environment + iqp_api_token = os.getenv("IQP_API_TOKEN") + + QiskitFunctionsCatalog.save_account(token=iqp_api_token) + ``` +
+ +6. Test your setup. Ensure that you can connect to the service: + +```python + from qiskit_ibm_runtime import QiskitRuntimeService + + service = QiskitRuntimeService() +``` ## Next steps From 8cf4f0f5310003d3ed961bfa5f2b65ab7f610330 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 14 Nov 2024 15:21:20 -0500 Subject: [PATCH 3/6] add to functions intro page --- docs/guides/functions.ipynb | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/guides/functions.ipynb b/docs/guides/functions.ipynb index 211d53cb1d9..b17e0bca521 100644 --- a/docs/guides/functions.ipynb +++ b/docs/guides/functions.ipynb @@ -73,7 +73,36 @@ "id": "42843fcd-1779-4a74-8d6a-7d00c22e374e", "metadata": {}, "source": [ - "Optionally, you can use the `save_account()` method to save your credentials for easy access later on, before initializing the service. This saves your credentials in the same place as `QiskitRuntimeService.save_account()`, so you can skip this step if you had previously used `QiskitRuntimeService` to save your account. *Note that account credentials are saved in plain text, so only do so if you are using a trusted device.*" + "Optionally, you can use the `save_account()` method to save your credentials for easy access later on, before initializing the service. This saves your credentials in the same place as `QiskitRuntimeService.save_account()`, so you can skip this step if you had previously used `QiskitRuntimeService` to save your account. *Note that account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; click the following collapsible section for more information.*\n", + "\n", + "
\n", + " \n", + " Securely manage your token with an environment variable\n", + " \n", + " To store sensitive information like account credentials more securely, it’s a good practice to use environment variables instead of saving them in plain text. Here’s how to modify your code to load the API token from an environment variable.\n", + "\n", + " 1. Set the environment variable:\n", + "\n", + " Set the `IQP_API_TOKEN` environment variable in your system. You can do this by adding the following line to your shell profile (for example, `.bashrc`, `.zshrc`) or by setting it directly in your terminal:\n", + "\n", + " ```bash\n", + " export IQP_API_TOKEN=\"\"\n", + " ```\n", + "\n", + " 2. Modify the code to retrieve the token from the environment variable\n", + "\n", + " Update your code to retrieve the token from the environment variable instead of saving it directly:\n", + "\n", + " ```python\n", + " import os\n", + " from qiskit_ibm_catalog import QiskitFunctionsCatalog\n", + "\n", + " # Gather the token from your environment\n", + " iqp_api_token = os.getenv(\"IQP_API_TOKEN\")\n", + "\n", + " QiskitFunctionsCatalog.save_account(token=iqp_api_token)\n", + " ``` \n", + "
" ] }, { From 880a54102a224a29b7eb8cfc4b4d21b2171eb60c Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Thu, 14 Nov 2024 15:25:04 -0500 Subject: [PATCH 4/6] squeaky --- docs/guides/functions.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/functions.ipynb b/docs/guides/functions.ipynb index b17e0bca521..9df772a5ec1 100644 --- a/docs/guides/functions.ipynb +++ b/docs/guides/functions.ipynb @@ -101,7 +101,7 @@ " iqp_api_token = os.getenv(\"IQP_API_TOKEN\")\n", "\n", " QiskitFunctionsCatalog.save_account(token=iqp_api_token)\n", - " ``` \n", + " ```\n", "" ] }, From 8e7b1bd8af33276d5e8cd258cba39f682612a0c1 Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Fri, 15 Nov 2024 11:48:39 -0500 Subject: [PATCH 5/6] add separate section --- docs/guides/functions.ipynb | 31 +----------- docs/guides/setup-channel.mdx | 94 ++++++++++------------------------- 2 files changed, 27 insertions(+), 98 deletions(-) diff --git a/docs/guides/functions.ipynb b/docs/guides/functions.ipynb index 9df772a5ec1..20cf6f46582 100644 --- a/docs/guides/functions.ipynb +++ b/docs/guides/functions.ipynb @@ -73,36 +73,7 @@ "id": "42843fcd-1779-4a74-8d6a-7d00c22e374e", "metadata": {}, "source": [ - "Optionally, you can use the `save_account()` method to save your credentials for easy access later on, before initializing the service. This saves your credentials in the same place as `QiskitRuntimeService.save_account()`, so you can skip this step if you had previously used `QiskitRuntimeService` to save your account. *Note that account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; click the following collapsible section for more information.*\n", - "\n", - "
\n", - " \n", - " Securely manage your token with an environment variable\n", - " \n", - " To store sensitive information like account credentials more securely, it’s a good practice to use environment variables instead of saving them in plain text. Here’s how to modify your code to load the API token from an environment variable.\n", - "\n", - " 1. Set the environment variable:\n", - "\n", - " Set the `IQP_API_TOKEN` environment variable in your system. You can do this by adding the following line to your shell profile (for example, `.bashrc`, `.zshrc`) or by setting it directly in your terminal:\n", - "\n", - " ```bash\n", - " export IQP_API_TOKEN=\"\"\n", - " ```\n", - "\n", - " 2. Modify the code to retrieve the token from the environment variable\n", - "\n", - " Update your code to retrieve the token from the environment variable instead of saving it directly:\n", - "\n", - " ```python\n", - " import os\n", - " from qiskit_ibm_catalog import QiskitFunctionsCatalog\n", - "\n", - " # Gather the token from your environment\n", - " iqp_api_token = os.getenv(\"IQP_API_TOKEN\")\n", - "\n", - " QiskitFunctionsCatalog.save_account(token=iqp_api_token)\n", - " ```\n", - "
" + "Optionally, you can use the `save_account()` method to save your credentials for easy access later on, before initializing the service. This saves your credentials in the same place as `QiskitRuntimeService.save_account()`, so you can skip this step if you had previously used `QiskitRuntimeService` to save your account. *Note that account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](/guides/setup-channel#securely-manage) section for more information.*" ] }, { diff --git a/docs/guides/setup-channel.mdx b/docs/guides/setup-channel.mdx index 638afbc819b..b8b94dc175e 100644 --- a/docs/guides/setup-channel.mdx +++ b/docs/guides/setup-channel.mdx @@ -59,7 +59,7 @@ Available plans: ``` - Or, optionally use the `save_account()` method to save your credentials for easy access later on, before initializing the service. + Or, optionally use the `save_account()` method to save your credentials for easy access later on, before initializing the service. *Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](#securely-manage) section for more information.* ```python from qiskit_ibm_runtime import QiskitRuntimeService @@ -84,49 +84,9 @@ Available plans: * The `channel` parameter allows you to distinguish between different account types. When initializing the account, IBM Cloud is the default account used if have saved credentials for an IBM Quantum Platform and an IBM Cloud account. - Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; click the following collapsible section for more information. + Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](#securely-manage) section for more information. -
- - Securely manage your token with an environment variable - - To store sensitive information like account credentials more securely, it’s a good practice to use environment variables instead of saving them in plain text. Here’s how to modify your code to load the API token from an environment variable. - - 1. Set the environment variable: - - Set the `IQP_API_TOKEN` environment variable in your system. You can do this by adding the following line to your shell profile (for example, `.bashrc`, `.zshrc`) or by setting it directly in your terminal: - - ```bash - export IQP_API_TOKEN="" - ``` - - 2. Modify the code to retrieve the token from the environment variable - - Update your code to retrieve the token from the environment variable instead of saving it directly: - - ```python - import os - from qiskit_ibm_catalog import QiskitFunctionsCatalog - - # Gather the token from your environment - iqp_api_token = os.getenv("IQP_API_TOKEN") - - QiskitFunctionsCatalog.save_account(token=iqp_api_token) - ``` -
- - - IBM Cloud is the default account used if you don't specify a different channel or account name. - - - - 1. Test your setup. Run a simple circuit using Sampler to ensure that your environment is set up properly: ```python @@ -241,7 +201,7 @@ Alternatively, you can also access quantum processors with REST APIs, enabling y service = QiskitRuntimeService(channel="ibm_cloud", token="", instance="") ``` - You can optionally use the `save_account()` method to save your credentials for easy access later on, before initializing the service. + You can optionally use the `save_account()` method to save your credentials for easy access later on, before initializing the service. *Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](#securely-manage) section for more information.* ```python from qiskit_ibm_runtime import QiskitRuntimeService @@ -267,45 +227,43 @@ Alternatively, you can also access quantum processors with REST APIs, enabling y - Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; click the following collapsible section for more information. + Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](#securely-manage) section for more information. -
- - Securely manage your token with an environment variable - - To store sensitive information like account credentials more securely, it’s a good practice to use environment variables instead of saving them in plain text. Here’s how to modify your code to load the API token from an environment variable. +6. Test your setup. Ensure that you can connect to the service: - 1. Set the environment variable: +```python + from qiskit_ibm_runtime import QiskitRuntimeService - Set the `IQP_API_TOKEN` environment variable in your system. You can do this by adding the following line to your shell profile (for example, `.bashrc`, `.zshrc`) or by setting it directly in your terminal: + service = QiskitRuntimeService() +``` - ```bash - export IQP_API_TOKEN="" - ``` + +## Securely manage your token - 2. Modify the code to retrieve the token from the environment variable +To store sensitive information like account credentials more securely, it’s a good practice to use environment variables instead of saving them in plain text. Here’s how to modify your code to load the API token from an environment variable. - Update your code to retrieve the token from the environment variable instead of saving it directly: +1. Set the environment variable. - ```python - import os - from qiskit_ibm_catalog import QiskitFunctionsCatalog +Set the `IQP_API_TOKEN` environment variable in your system. You can do this by adding the following line to your shell profile (for example, `.bashrc`, `.zshrc`) or by setting it directly in your terminal: - # Gather the token from your environment - iqp_api_token = os.getenv("IQP_API_TOKEN") +```bash +export IQP_API_TOKEN="" +``` - QiskitFunctionsCatalog.save_account(token=iqp_api_token) - ``` -
+2. Modify the code to retrieve the token from the environment variable. -6. Test your setup. Ensure that you can connect to the service: +Update your code to retrieve the token from the environment variable instead of saving it directly: ```python - from qiskit_ibm_runtime import QiskitRuntimeService +import os +from qiskit_ibm_catalog import QiskitFunctionsCatalog - service = QiskitRuntimeService() -``` +# Gather the token from your environment +iqp_api_token = os.getenv("IQP_API_TOKEN") + +QiskitFunctionsCatalog.save_account(token=iqp_api_token) +``` ## Next steps From 929a1a05e45eef5a0bbb601f8dac33d35c907cdb Mon Sep 17 00:00:00 2001 From: ABBY CROSS Date: Fri, 15 Nov 2024 11:57:52 -0500 Subject: [PATCH 6/6] tweak --- docs/guides/setup-channel.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/setup-channel.mdx b/docs/guides/setup-channel.mdx index b8b94dc175e..45fc6f2e5bf 100644 --- a/docs/guides/setup-channel.mdx +++ b/docs/guides/setup-channel.mdx @@ -59,7 +59,7 @@ Available plans: ``` - Or, optionally use the `save_account()` method to save your credentials for easy access later on, before initializing the service. *Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](#securely-manage) section for more information.* + Or, optionally use the `save_account()` method to save your credentials for easy access later on, before initializing the service. *Note that account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](#securely-manage) section for more information.* ```python from qiskit_ibm_runtime import QiskitRuntimeService @@ -201,7 +201,7 @@ Alternatively, you can also access quantum processors with REST APIs, enabling y service = QiskitRuntimeService(channel="ibm_cloud", token="", instance="") ``` - You can optionally use the `save_account()` method to save your credentials for easy access later on, before initializing the service. *Account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](#securely-manage) section for more information.* + You can optionally use the `save_account()` method to save your credentials for easy access later on, before initializing the service. *Note that account credentials are saved in plain text. To more securely manage your token, it is recommended to use an environment variable; see the [Securely manage your token](#securely-manage) section for more information.* ```python from qiskit_ibm_runtime import QiskitRuntimeService