{ "info": { "_postman_id": "1e8344a6-a443-4ea9-b7bf-b22a79f51445", "name": "Authentication Tutorial", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Get Access Token", "event": [ { "listen": "test", "script": { "exec": [ "// Token requests are expected to return a `200 Success` response code. Any", "// other response code should trigger a failure.", "pm.test(\"must return `200 Success` status\", function() {", " pm.response.to.have.status(200);", "})", "", "// The response should include an `access_token` value - this will be presented", "// to authenticated API endpoints in the `Authentication` header (see the last", "// testing code block for details on how this is persisted).", "pm.test(\"response body must include non-empty access_token\", function () {", " const { access_token } = pm.response.json()", " pm.expect(access_token).to.be.a('string').that.is.not.empty;", "});", "", "// The type of `access_token` returned by the token request is expected to be", "// `Bearer`.", "pm.test(\"response body must represent `Bearer` token\", function() {", " const { token_type } = pm.response.json()", " pm.expect(token_type).to.equal(\"Bearer\");", "});", "", "// The returned data includes an `expires_in` field that indicates time until", "// token expiration. Validate that this value is a whole number greater than", "// zero, as anything less than or equal to zero means that the `access_token`", "// is already expired.", "pm.test(\"returned token must expire in the future\", function() {", " const { expires_in } = pm.response.json()", " pm.expect(expires_in).to.be.above(0);", "});" ], "type": "text/javascript" } } ], "request": { "method": "POST", "header": [], "body": { "mode": "urlencoded", "urlencoded": [ { "key": "audience", "value": "{{TOKEN_AUDIENCE}}", "type": "text" }, { "key": "client_id", "value": "{{CLIENT_ID}}", "type": "text" }, { "key": "client_secret", "value": "{{CLIENT_SECRET}}", "type": "text" }, { "key": "grant_type", "value": "client_credentials", "type": "text" }, { "key": "scope", "value": "{{CLIENT_SCOPE}}", "type": "text" } ] }, "url": { "raw": "{{TOKEN_ENDPOINT}}", "host": [ "{{TOKEN_ENDPOINT}}" ] } }, "response": [] } ], "event": [ { "listen": "prerequest", "script": { "type": "text/javascript", "exec": [ "pm.request.headers.add({key: 'User-Agent', value: 'W3C Traceability Interop Tests'});" ] } }, { "listen": "test", "script": { "type": "text/javascript", "exec": [ "" ] } } ], "variable": [ { "key": "foo", "value": "" }, { "key": "credential_issuer_id", "value": "" }, { "key": "access_token", "value": "" } ] }