6.1. Install and Start the E-Commerce Service¶

To install and start the edX E-Commerce service, you must complete the following steps.

Note

These steps assume that you are running Open edX devstack. If you prefer to run the E-Commerce service locally on your computer instead of on the virtual machine (VM) that devstack uses, see Development Outside Devstack.

6.1.1. Set Up a Virtual Environment¶

1. Create or activate a Python virtual environment. You execute all of the commands described in this section within the virtualenv (unless otherwise noted).

$make requirements  3. (Optional) Create settings overrides that you do not commit to the repository. To do this, create a file named ecommerce/settings/private.py. The ecommerce/settings/local.py file reads the values in this file, but Git ignores the file. 6.1.2. Configure edX OpenID Connect (OIDC)¶ The E-Commerce service relies on the edX OpenID Connect (OIDC) authentication provider for login. OIDC is built on top of OAuth 2.0. Currently, the LMS serves as the authentication provider. To configure the E-Commerce service to work with OIDC, complete the following procedures. 6.1.2.1. Create and Register a Client¶ To create and register a new OIDC client, follow these steps. 1. Start the LMS. 2. In your browser, go to http://127.0.0.1:8000/admin/oauth2/client/. 3. Select Add client. 4. Leave the User field blank. 5. For Client Name, enter E-Commerce Service. 6. For URL, enter http://localhost:8002/. 7. For Redirect URL, enter https://localhost:8002/complete/edx-oidc/. This is the OIDC client endpoint. The system automatically generates values in the Client ID and Client Secret fields. You use these values when you update Django settings. 8. For Client Type, select Confidential (Web applications). 9. Select Save. 6.1.2.2. Designate the Client as Trusted¶ After you create your client, designate it as trusted. Trusted clients bypass the user consent form that usually appears after the system validates the user’s credentials. To designate your client as trusted, follow these steps. 1. In your browser, go to http://127.0.0.1:8000/admin/oauth2_provider/trustedclient/add/. 2. In the OAuth 2.0 clients list, select the redirect URL for the client that you just created. 3. Select Save. 6.1.2.3. Update Django Settings¶ To finish creating and configuring your OIDC client, add the client credentials to the Django settings for your project. In the ecommerce/settings/local.py file, update the following settings. Setting Description Value SOCIAL_AUTH_EDX_OIDC_KEY OAuth 2.0 client key Enter the value from the Client ID field in the Create and Register a Client section. SOCIAL_AUTH_EDX_OIDC_SECRET OAuth 2.0 client secret Enter the value from the Client Secret field in the Create and Register a Client section. SOCIAL_AUTH_EDX_OIDC_URL_ROOT OAuth 2.0 authentication URL Enter http://127.0.0.1:8000/oauth2. SOCIAL_AUTH_EDX_OIDC_ID_TOKEN_DECRYPTION_KEY OIDC ID token decryption key, used to validate the ID token Set this to the same value as SOCIAL_AUTH_EDX_OIDC_SECRET. 6.1.3. Run Migrations and Start the Server¶ To complete the installation and start the E-Commerce service, follow these steps. Note Local installations use SQLite by default. If you use another database backend, make sure you update your settings and create the database, if necessary, before you run migrations. 1. (Devstack only) If you are using devstack, switch to the ecommerce user and use the ecommerce.settings.devstack settings module to run the following commands. $ sudo su ecommerce
$make devserve  2. To run migrations, execute the following command. $ make migrate