{ "info": { "_postman_id": "8780c459-67c0-46ae-8f05-ddbd021df0d3", "name": "Adobe I/O JWT - Medium", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "INIT: Load Crypto Library for RS256", "event": [ { "listen": "test", "script": { "id": "824e628b-b420-417b-894b-417ab6412896", "type": "text/javascript", "exec": [ "postman.setGlobalVariable(\"jsrsasign_js\", responseBody);" ] } } ], "request": { "method": "GET", "header": [], "url": { "raw": "http://kjur.github.io/jsrsasign/jsrsasign-latest-all-min.js", "protocol": "http", "host": [ "kjur", "github", "io" ], "path": [ "jsrsasign", "jsrsasign-latest-all-min.js" ] }, "description": "Load the RSA-Sign Crypto LIbrary in a global environment variable\n\nSource: http://kjur.github.io/jsrsasign/jsrsasign-latest-all-min.js\n\nGithub: https://github.com/kjur/jsrsasign" }, "response": [] }, { "name": "IMS: JWT Generate + Auth", "event": [ { "listen": "test", "script": { "id": "1759a9d4-ac9a-4eb2-b5d1-a608a43a2cad", "exec": [ "var data = JSON.parse(responseBody);", "postman.setEnvironmentVariable(\"ACCESS_TOKEN\", data.access_token);" ], "type": "text/javascript" } }, { "listen": "prerequest", "script": { "id": "f067b81f-65d2-4672-ae41-0ff1338d25f6", "exec": [ "// Tips from: https://github.com/kjur/jsrsasign/issues/199", "// https://github.com/kjur/jsrsasign/wiki/Tutorial-for-JWT-generation", "", "var navigator = {}; //fake a navigator object for the lib", "var window = {}; //fake a window object for the lib", "eval(postman.getGlobalVariable(\"jsrsasign_js\")); //import javascript jsrsasign", "", "", "var header = {", "\t\"alg\": \"RS256\"", "};", "", "var data = {", "\t\"exp\": Math.round(87000 + Date.now()/1000),", "\t\"iss\": postman.getEnvironmentVariable(\"IMS_ORG\"),", "\t\"sub\": postman.getEnvironmentVariable(\"TECHNICAL_ACCOUNT_ID\"),", "\t\"aud\": \"https://\" + postman.getEnvironmentVariable(\"IMS\")+\"/c/\"+postman.getEnvironmentVariable(\"API_KEY\")", "};", "", "meta_scopes = postman.getEnvironmentVariable(\"META_SCOPE\");", "if(typeof(meta_scopes) == \"string\") {", " meta_scopes = meta_scopes.split(',');", "}", "meta_scopes.forEach(function(scope){", " var meta_scope = \"https://\" + postman.getEnvironmentVariable(\"IMS\")+\"/s/\"+", " scope;", " data[meta_scope] = true;", "});", "", "var secret = postman.getEnvironmentVariable(\"PRIVATE_KEY\");", "", "if (!secret) {", " console.log(\"Ensure the Private Key is added to both INITIAL and CURRENT VALUES in the active Postman environment's PRIVATE_KEY variable.\");", "}", "", "console.log(data);", "", "var sHeader = JSON.stringify(header);", "var sPayload = JSON.stringify(data);", "var sJWT = KJUR.jws.JWS.sign(\"RS256\", sHeader, sPayload, secret);", "", "console.log(sJWT);", "", "postman.setEnvironmentVariable(\"JWT_TOKEN\", sJWT);" ], "type": "text/javascript" } } ], "request": { "method": "POST", "header": [], "body": { "mode": "formdata", "formdata": [ { "key": "client_id", "value": "{{API_KEY}}", "type": "text" }, { "key": "client_secret", "value": "{{CLIENT_SECRET}}", "type": "text" }, { "key": "jwt_token", "value": "{{JWT_TOKEN}}", "type": "text" } ] }, "url": { "raw": "https://{{IMS}}/ims/exchange/jwt/", "protocol": "https", "host": [ "{{IMS}}" ], "path": [ "ims", "exchange", "jwt", "" ] }, "description": "Generate a JWT token using the Crypto RS256\nSend to IMS for access_token" }, "response": [] }, { "name": "IMS: Get Profile", "request": { "method": "GET", "header": [ { "key": "Authorization", "value": "Bearer {{ACCESS_TOKEN}}" } ], "url": { "raw": "https://{{IMS}}/ims/profile/v1", "protocol": "https", "host": [ "{{IMS}}" ], "path": [ "ims", "profile", "v1" ] } }, "response": [] }, { "name": "Catalog: Get Datasets Copy", "request": { "method": "GET", "header": [ { "key": "Authorization", "value": "Bearer {{ACCESS_TOKEN}}" }, { "key": "x-api-key", "value": "{{API_KEY}}" }, { "key": "x-gw-ims-org-id", "value": "{{IMS_ORG}}" } ], "url": { "raw": "{{PLATFORM_GATEWAY}}/data/foundation/catalog/dataSets/", "host": [ "{{PLATFORM_GATEWAY}}" ], "path": [ "data", "foundation", "catalog", "dataSets", "" ] }, "description": " " }, "response": [] } ], "event": [ { "listen": "prerequest", "script": { "id": "d40e8149-1eb7-4f85-a4d2-b8664450757f", "type": "text/javascript", "exec": [ "" ] } }, { "listen": "test", "script": { "id": "0667bacc-03ba-4071-80ec-7957274b2889", "type": "text/javascript", "exec": [ "" ] } } ], "protocolProfileBehavior": {} }