Create OAuth2 Client Application in IDCS
Use Retail Home for creating the client app in IDCS. Once app is created you will get client id and client secret both of them necessary to get access token. Follow the instructions below for generating the access token and making service call using OAuth2 token.
-
Login into retail home as retail home administrator.
-
In retail home screen click on Settings menu icon on the left and then click on Application Administration.
-
On the Application Administration menu click on Application Navigator Setup. Notice all the hosted applications are listed here with their application and plat-form service url.
Settings -> Application Administration->Application Navigator Settings
-
Look for application with name RICS. If you are not seeing RICS application try refreshing seed. Steps
-
Select the row with the application code as Rms.
-
Click the Refresh Seed Data button on top right corner of the menu.
-
Wait for some time and refresh the screen.
-
RICS should reflect now.
-
-
If RICS application is not reflecting even after following step 4. Select the row with the application code as Rms and click on the Actions menu on top left. Select Create IDCS OAuth 2.0 Client. A dialog will open for entering oauth2 client details.
Note:
Create IDCS OAuth 2.0 Client option is available only for applications those have platform service URL mentioned. RICS is making use of merch platform service as both the apps are sharing same IDCS tenancy.
-
Skip this step if RICS application is not showing up. One of either Step 5 or Step 6 needs to be followed.
Select a row with application code as RICS. Click on the Actions menu on top left and select Create IDCS OAuth 2.0 Client. A dialog will open for entering oauth2 client details.
-
This dialog takes the following values:
App Name is 2-100 characters and will be used as the name in IDCS. Provide unique application name.
Description is a detailed description of the application.
Scope: <Custom environment-specific scope>
The scope pattern that is used in the RICS IDCS app creation template is rgbu:rics:<SERVICETYPE>-<ENVIRONMENT> where SERVICETYPE is RICS and ENVIRONMENT is the environment type (STG, PRD, UAT, DEV1, DEV2, and so on).
For example:
"scope": "rgbu:rics:RICS-PRD""scope": "rgbu:rics:RICS-STG"
-
When the application is created, another dialog will open to show the client ID and client secret of the new application. These values should be copied down to a safe location, as they will only be shown once. Retail Home cannot retrieve the credentials again after the dialog is closed.
-
Client ID and Client Secret from previous step will be used for generating access token.
Sample code for generating Access Token:
clientId=RICS_TEST_APPID clientSecret=998e1e1d-f146-45a5-a9a1-99785e3ebf43 idcsUrl=https://idcs-234e8f7334564936aa0ed93f2c39e9ca.identity.pint.oc9qadev.com scope=rgbu:rics:RICS-STG99 ec=$(echo -n "$clientId:$clientSecret" | base64 -w 0) AccessToken=$(curl -iv \ -H "Authorization: Basic $ec" \ -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" \ --request POST $idcsUrl/oauth2/v1/token \ -d "grant_type=client_credentials&scope=$scope" | grep -o -P '(?<=access_token":").*(?=","token_type)') echo $AccessToken
-
Now service call can be made by passing along the access token generated in previous step.
Here is sample curl command with Bearer token and rib-ext publisher ping
ribExtServiceUrl=https://rex.retail.us-phoenix-1.ocs.oc-test.com:443/rgbu-rex-eit-stg99-rics/rib-ext-services-web/resources/publisher/ping curl -ivkL --noproxy '*' -H "Authorization: Bearer $AccessToken" -H "Content-Type: application/xml" -X GET $ri-bExtServiceUrl
Sample response
{"message": "ping() was called with input String of: hello"}
-
Publishing a message using access token.
Here is sample curl for publishing a message
ribExtServiceUrl=https://rex.retail.us-phoenix-1.ocs.oc-test.com:443/rgbu-rex-eit-stg99-rics/rib-ext-services-web/resources/publisher/publish curl -ivkL --noproxy '*' -H "Authorization: Bearer $AccessToken" -H "Content-Type: application/xml" -X POST $ribExtServiceUrl --data '<v1:ApplicationMessages xmlns:v1="http://www.oracle.com/retail/integration/rib/ApplicationMessages/v1"> <v1:ApplicationMessage> <v1:family>InvAdjust</v1:family> <v1:type>InvAdjustCre</v1:type> <v1:payloadXml><InvAdjustDesc xmlns="http://www.oracle.com/retail/integration/base/bo/InvAdjustDesc/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oracle.com/retail/integration/base/bo/InvAdjustDesc/v1 http://www.oracle.com/retail/integration/base/bo/InvAdjustDesc/v1/InvAdjustDesc.xsd" ;><dc_dest_id>DC_ES</dc_dest_id><InvAdjustDtl><item_id>Aline</item_id><adjustment_reason_code>stri</adjustment_reason_code><unit_qty>22.4</unit_qty> ;<transshipment_nbr>ss</transshipment_nbr><from_disposition>ss</from_disposition><to_disposition>sss</to_disposition><from_trouble_code>sss</from_trouble_code> <to_trouble_code>ss</to_trouble_code><from_wip_code>aaa</from_wip_code><to_wip_code>sss</to_wip_code><transaction_code>4</transaction_code><user_id>TestUser</user_id> <create_date>1999-10-23T20:27:56.32</create_date><po_nbr>PratapOrd96</po_nbr><doc_type>P</doc_type><aux_reason_code>string</aux_reason_code> <weight>12.4</weight><weight_uom>smn;</weight_uom><unit_cost>20.4</unit_cost><InvAdjustUin><uin>123</uin> <status>4</status></InvAdjustUin></InvAdjustDtl></InvAdjustDesc></v1:payloadXml> </v1:ApplicationMessage> </v1:ApplicationMessages>'
Sample response
{"message": "Publish done"}