Support for IDEs

Leap supports third-party IDEs, both local and cloud-based, that implement the Development Containers specification (aka “devcontainers”). Although any IDE that implements devcontainers is supported, D-Wave recommends GitHub Codespaces.

The Ocean SDK releases 6.6 and higher enable Leap authentication using the secure OAuth 2.0 industry standard. The Authorizing Access to Leap procedure described here simplifies the retrieval and storage of your Solver API (SAPI) token for use in submitting problems to Leap solvers from the third-party IDE of your choice.

For an overview about developing quantum applications, see Workflow for Developing Quantum Applications; for a beginner’s introduction, see the Getting Started with D-Wave Solvers guide. Also see end-to-end examples of D-Wave quantum applications in GitHub.

Requirements

If you configure your IDE to use Ocean-Dev Docker Images, your development environment is updated with a recent Ocean SDK. You can see an example here.

Authorizing Access to Leap

As described in the Ocean software’s Configuring Access to Leap’s Solvers documentation, you require a SAPI token to submit problems to Leap solvers. The following procedure authorizes the Ocean software access to your Leap account and enables storing your SAPI token in your development environment. Ocean authorization to access Leap is persisted across subsequent development sessions for this development environment.

Note

The following OAuth-based procedure is provided for convenience but you also have the option of manually copying your SAPI token from Leap. The Ocean software’s Configuring Access to Leap’s Solvers documentation provides more information.

This procedure uses the Ocean CLI commands that you enter into your terminal. You can see help documentation for these commands and all their options with the CLI’s --help option.1

  1. For any new developer environment (for example, a Python virtual environment or a GitHub Codespaces codespace), authorize the Ocean software access to your Leap account, using the secure OAuth 2.0 code exchange, by running one of the following Ocean CLI commands from your terminal.

    • In an environment such as an IDE installed on your system, where you can access localhost addresses from your browser, initiate the OAuth redirect flow:

      dwave auth login
      
    • In an environment such as a cloud IDE, where access to localhost addresses from your browser might be blocked, you can initiate the alternative OAuth out-of-band flow:

      dwave auth login --oob
      
  2. If you are not currently logged into Leap, you are asked to enter your Leap account’s credentials.

    Figure 116 shows the Leap login screen opened in a browser tab.

    image

    Fig. 116 Leap login screen

  3. When you are logged into your Leap account, you are asked to grant the Ocean software permission to fetch an authorization code from Leap.

    Figure 117 shows the authorization request opened in a browser tab.

    image

    Fig. 117 Authorization request screen

    Click the Authorize button.

    For the OAuth redirect flow, the authorization code is now stored in your development environment; for the OAuth out-of-band flow, your browser displays the authorization code.

  4. For the OAuth out-of-band flow only, copy the authorization code to your terminal’s “Authorization code:” prompt, similar to the representative shell lines shown below:

    $ dwave auth login --oob
    Please visit the following URL to authorize Ocean:
    https://leap.dwavesystems.com/leap/openid/authorize?response_type=code&client_id=96...
    
    Authorization code: 717983...
    

    Figure 118 shows the authorization code returned in a browser tab for you to copy to the terminal prompt.

    image

    Fig. 118 Authorization code screen

  5. Create a dwave-cloud-client configuration file to manage your SAPI access by running the following Ocean CLI command from your terminal:

    dwave config create --auto-token
    
  6. Validate the configuration by running the following Ocean CLI command in your terminal:

    dwave ping
    

If you cloned a D-Wave example, you can now run it.

1

Below are some examples of displaying commands, options, and help documentation for the dwave-cloud-client CLI (produced on version 0.11.0). For more information, see the Ocean CLI documentation.

  • Display all CLI commands:

    $ dwave --help
    Usage: dwave [OPTIONS] COMMAND [ARGS]...
    
        D-Wave Cloud Client interactive configuration tool.
    
    Options:
        --version    Show the version and exit.
    
    ... <Snipped above for brevity>
    
    Commands:
        auth     Authorize Leap access and fetch Leap/Solver API tokens.
        config   Create, update or inspect cloud client configuration file(s).
        install  Install optional non-open-source Ocean packages.
        leap     Interact with Leap API.
        ping     Ping the QPU by submitting a single-qubit problem.
        ... <Snipped here due to length>
    
  • Display help on a particular CLI command:

    $ dwave auth --help
    Usage: dwave auth [OPTIONS] COMMAND [ARGS]...
    
    Authorize Leap access and fetch Leap/Solver API tokens.
    
    Options:
        --help  Show this message and exit.
    
    Commands:
        get      Fetch Leap API token.
        login    Authorize Ocean to access Leap API on user's behalf.
        refresh  Refresh Leap API access token.
    
  • Display the options available to a particular CLI command:

    $ dwave auth login --help
    Usage: dwave auth login [OPTIONS]
    
    Authorize Ocean to access Leap API on user's behalf.
    
    Options:
        -p, --profile TEXT      Connection profile (section) name
        -f, --config-file FILE  Configuration file path
        --oob                   Run OAuth 2.0 Authorization Code flow out-of-band,
                                without the use of locally hosted redirect URL.
        --help                  Show this message and exit.