Enabling Interactive OCC REST API Documentation

OAuth clients need to be defined and authorized to enable the interactive OCC REST API documentation.

Context

Interactive OCC REST API Documentation is currently supported in B2C Accelerator.

Procedure

  1. Register a user on your storefront.
  2. Open the ImpEx Import page in SAP Commerce Cloud Administration Console: https://localhost:9002/console/impex/import.
  3. Copy the following ImpEx data:
    INSERT_UPDATE OAuthClientDetails;clientId[unique=true]    ;resourceIds       ;scope        ;authorizedGrantTypes                                            ;authorities             ;clientSecret    ;registeredRedirectUri
                                    ;client-side              ;hybris            ;basic        ;implicit,client_credentials                                     ;ROLE_CLIENT             ;secret          ;http://localhost:9001/authorizationserver/oauth2_implicit_callback;
                                    ;mobile_android           ;hybris            ;basic        ;authorization_code,refresh_token,password,client_credentials    ;ROLE_CLIENT             ;secret          ;http://localhost:9001/authorizationserver/oauth2_callback;
    This ImpEx data provides you with a user called mobile_android, and a corresponding password, secret. This data is used to enable the interactive calls in the OCC REST API documentation.
  4. Paste the ImpEx data into the Import content window, then click Import content.
  5. Copy the following ImpEx data:
    INSERT_UPDATE OAuthClientDetails;clientId[unique=true]    ;resourceIds       ;scope        ;authorizedGrantTypes                                            ;authorities             ;clientSecret    ;registeredRedirectUri 
                                    ;trusted_client           ;hybris            ;extended     ;authorization_code,refresh_token,password,client_credentials    ;ROLE_TRUSTED_CLIENT     ;secret;         ;
    This ImpEx data provides you with a user called trusted_client with a corresponding password. This data is used to enable the interactive calls in the OCC REST API documentation that require extended permissions.
  6. Paste the ImpEx data into the Import content window, then click Import content.
  7. Open the interactive OCC REST API documentation in your web browser by accessing the following link: http://<hostname>:<port>/rest/v2/swagger-ui.html.
    For example, if you have a storefront installed on your local machine, you can access the OCC REST API documentation with the following link: https://localhost:9002/rest/v2/swagger-ui.html.
  8. Click Authorize at the top of the OCC REST API documentation web page.
  9. In the Available authorizations window that appears, enter the credentials of your storefront user in the Username and Password fields.
  10. In the Type drop-down list, select Basic auth.
  11. In the ClientId field that appears, enter mobile_android, and in the Secret field, enter secret.
  12. Select the basic checkbox and click Authorize.

    The steps that follow are for authorizing the trusted_client user.

  13. Click Authorize at the top of the OCC REST API documentation web page.
  14. In the Available authorizations window that appears, scroll down to the second OAuth2.0 section, then select Basic auth from the Type drop-down list.
  15. In the ClientId field that appears, enter trusted_client, and in the Secret field, enter secret.
  16. Select the extended checkbox and click Authorize.