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
- Register a user on your storefront.
- Open the ImpEx Import page in SAP Commerce Cloud Administration Console: https://localhost:9002/console/impex/import.
- 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.
- Paste the ImpEx data into the Import content window, then click Import content.
- 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.
- Paste the ImpEx data into the Import content window, then click Import content.
- 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.
- Click Authorize at the top of the OCC REST API documentation web page.
- In the Available authorizations window that appears, enter the credentials of your storefront user in the Username and Password fields.
- In the Type drop-down list, select Basic auth.
- In the ClientId field that appears, enter mobile_android, and in the Secret field, enter secret.
- Select the basic checkbox and click Authorize.
The steps that follow are for authorizing the trusted_client user.
- Click Authorize at the top of the OCC REST API documentation web page.
- 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.
- In the ClientId field that appears, enter trusted_client, and in the Secret field, enter secret.
- Select the extended checkbox and click Authorize.