Created
August 26, 2020 19:31
-
-
Save kevinswiber/252eccbe557b0bb76ecdaa15db31660c to your computer and use it in GitHub Desktop.
Postman Basic Auth example
This file contains hidden or 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": "f8ee6daf-36ee-404c-9c5b-107a9fbee6b6", | |
"name": "Basic Auth", | |
"description": "An example of using Basic Auth in Postman.", | |
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | |
}, | |
"item": [ | |
{ | |
"name": "Basic Auth", | |
"event": [ | |
{ | |
"listen": "test", | |
"script": { | |
"id": "cef1ec7c-390a-44c1-bc5e-a8fcbb6d2590", | |
"exec": [ | |
"pm.test(\"response is ok\", function () {", | |
" pm.response.to.have.status(200);", | |
"});", | |
"", | |
"pm.test(\"response body has json saying 'authenticated'\", function () {", | |
" pm.response.to.have.jsonBody('authenticated', true);", | |
"});" | |
], | |
"type": "text/javascript" | |
} | |
} | |
], | |
"request": { | |
"auth": { | |
"type": "basic", | |
"basic": [ | |
{ | |
"key": "username", | |
"value": "postman", | |
"type": "string" | |
}, | |
{ | |
"key": "password", | |
"value": "password", | |
"type": "string" | |
}, | |
{ | |
"key": "showPassword", | |
"value": false, | |
"type": "boolean" | |
} | |
] | |
}, | |
"method": "GET", | |
"header": [], | |
"url": { | |
"raw": "https://postman-echo.com/basic-auth", | |
"protocol": "https", | |
"host": [ | |
"postman-echo", | |
"com" | |
], | |
"path": [ | |
"basic-auth" | |
] | |
}, | |
"description": "This endpoint simulates a **basic-auth** protected endpoint. \nThe endpoint accepts a default username and password and returns a status code of `200 ok` only if the same is provided. \nOtherwise it will return a status code `401 unauthorized`.\n\n> Username: `postman`\n> \n> Password: `password`\n\nTo use this endpoint, send a request with the header `Authorization: Basic cG9zdG1hbjpwYXNzd29yZA==`. \nThe cryptic latter half of the header value is a base64 encoded concatenation of the default username and password. \nUsing Postman, to send this request, you can simply fill in the username and password in the \"Authorization\" tab and Postman will do the rest for you.\n\nTo know more about basic authentication, refer to the [Basic Access Authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) wikipedia article.\nThe article on [authentication helpers](https://www.getpostman.com/docs/helpers#basic-auth?source=echo-collection-app-onboarding) elaborates how to use the same within the Postman app." | |
}, | |
"response": [] | |
} | |
], | |
"event": [ | |
{ | |
"listen": "prerequest", | |
"script": { | |
"id": "99aeb6bb-ba7b-42ab-97af-2e3ed9e389bb", | |
"type": "text/javascript", | |
"exec": [ | |
"" | |
] | |
} | |
}, | |
{ | |
"listen": "test", | |
"script": { | |
"id": "c6032d91-0c64-4388-8eaf-40fe570aa3a7", | |
"type": "text/javascript", | |
"exec": [ | |
"" | |
] | |
} | |
} | |
], | |
"protocolProfileBehavior": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment