OCAPI: Session Bridge Example (Guest token)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"info": { | |
"_postman_id": "fbba8172-d84a-42bd-ae58-4cb5a4ce2e34", | |
"name": "OCAPI: Session Bridge", | |
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", | |
"_exporter_id": "976887" | |
}, | |
"item": [ | |
{ | |
"name": "1. Get OAuth2 client token", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.collectionVariables.set(\"Authorization_key\", postman.getResponseHeader(\"Authorization\").replace('Bearer ', ''));" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "noauth" | |
}, | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "x-dw-client-id", | |
"value": "{{client_id}}", | |
"type": "text" | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\r\n \"type\": \"guest\"\r\n}", | |
"options": { | |
"raw": { | |
"language": "json" | |
} | |
} | |
}, | |
"url": { | |
"raw": "{{base_url}}/s/RefArch/dw/shop/v22_6/customers/auth", | |
"host": [ | |
"{{base_url}}" | |
], | |
"path": [ | |
"s", | |
"RefArch", | |
"dw", | |
"shop", | |
"v22_6", | |
"customers", | |
"auth" | |
] | |
}, | |
"description": "Fetches an anonymous JWT session token." | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "2. Exchange JWT for Cookie", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "bearer", | |
"bearer": [ | |
{ | |
"key": "token", | |
"value": "{{Authorization_key}}", | |
"type": "string" | |
} | |
] | |
}, | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "x-dw-client-id", | |
"value": "{{client_id}}" | |
} | |
], | |
"url": { | |
"raw": "{{base_url}}/s/RefArch/dw/shop/v22_6/sessions", | |
"host": [ | |
"{{base_url}}" | |
], | |
"path": [ | |
"s", | |
"RefArch", | |
"dw", | |
"shop", | |
"v22_6", | |
"sessions" | |
] | |
}, | |
"description": "Exchange the JWT for cookies by using the bearer token fetched in request 1." | |
}, | |
"response": [] | |
}, | |
{ | |
"name": "3. Exchange Cookie for JWT", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"exec": [ | |
"pm.collectionVariables.set('dwsid', pm.cookies.get('dwsid'));" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "noauth" | |
}, | |
"method": "POST", | |
"header": [ | |
{ | |
"key": "x-dw-client-id", | |
"value": "{{client_id}}" | |
} | |
], | |
"body": { | |
"mode": "raw", | |
"raw": "{\r\n \"type\": \"session\"\r\n}", | |
"options": { | |
"raw": { | |
"language": "json" | |
} | |
} | |
}, | |
"url": { | |
"raw": "{{base_url}}/s/RefArch/dw/shop/v22_6/customers/auth", | |
"host": [ | |
"{{base_url}}" | |
], | |
"path": [ | |
"s", | |
"RefArch", | |
"dw", | |
"shop", | |
"v22_6", | |
"customers", | |
"auth" | |
] | |
} | |
}, | |
"response": [] | |
} | |
], | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"type": "text/javascript", | |
"exec": [ | |
"" | |
] | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"type": "text/javascript", | |
"exec": [ | |
"" | |
] | |
} | |
} | |
], | |
"variable": [ | |
{ | |
"key": "Authorization_key", | |
"value": "" | |
}, | |
{ | |
"key": "client_id", | |
"value": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | |
}, | |
{ | |
"key": "client_pw", | |
"value": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | |
}, | |
{ | |
"key": "base_url", | |
"value": "https://xxxx-00x.sandbox.us01.dx.commercecloud.salesforce.com" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment