{"id":20447549,"url":"https://github.com/doamaral/postman-imgur","last_synced_at":"2026-03-01T08:34:14.504Z","repository":{"id":87569602,"uuid":"274548199","full_name":"doamaral/postman-imgur","owner":"doamaral","description":"Using Postman with Oauth2 and refreshing its token automatically using pre-request scripts","archived":false,"fork":false,"pushed_at":"2024-02-07T00:58:36.000Z","size":152,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-13T01:11:23.731Z","etag":null,"topics":["api","dynamic-variables","htmlextra","oauth2","postman","rest","testing"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/doamaral.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-06-24T01:41:44.000Z","updated_at":"2024-02-07T00:58:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"f362f561-029a-42cb-8644-93cf75b00fbc","html_url":"https://github.com/doamaral/postman-imgur","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/doamaral/postman-imgur","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpostman-imgur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpostman-imgur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpostman-imgur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpostman-imgur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doamaral","download_url":"https://codeload.github.com/doamaral/postman-imgur/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doamaral%2Fpostman-imgur/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29965406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T06:55:38.174Z","status":"ssl_error","status_checked_at":"2026-03-01T06:53:04.810Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","dynamic-variables","htmlextra","oauth2","postman","rest","testing"],"created_at":"2024-11-15T10:27:44.383Z","updated_at":"2026-03-01T08:34:14.478Z","avatar_url":"https://github.com/doamaral.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# postman-imgur\r\nUsing imgur public API to try some Postman's features including:\r\n - Environment and Collections Variables\r\n - Pre-requests and Tests scripts\r\n - Dynamic Variables\r\n - Oauth2 Authentication and refreshing its tokens when expired automatically using pre-request scripts\r\n - Fancy reports using HTMLEXTRA\r\n\r\n## Overview\r\n\r\n### Pre requisites\r\n- Node.js \u003e= v10\r\n- Newman: `npm install -g newman`\r\n- HTMLExtra: `npm install -g newman-reporter-htmlextra`\r\n\r\n## Running Tests using Newman\r\n\r\nDownload or Clone the project. Once you cd to the project folder:\r\n\r\n```\r\nnewman run \"imgur.postman_collection.json\" -e \"Imgur - PRD.postman_environment.json\" --iteration-count 1 --reporters cli,htmlextra\r\n```\r\n\r\nwhere:\r\n - `--iteration-count`: is the number of iterations (repetitions)\r\n - `--reporters`: the test execution outputs\r\n   - cli: the prompt/terminal\r\n   - html: default newman's html report generator\r\n   - htmlextra: a fancy report template\r\n\r\n### Variables\r\n\r\n#### Environment\r\n- `baseUrl`: https://api.imgur.com\r\n- `version`: api version, initially equals to 3\r\n- `clientId` and `clientSecret`: obtained when you subscribe your app at imgur service\r\n- `accessToken` and `refreshToken`: used to store its respectives values when we get it\r\n\r\n#### Collection\r\n\r\n- `expiresIn`: To control the Token Expiration\r\n- `tokenTimestamp`: Set the Time of the Token creation\r\n- `prefixList`: List of preffixes that can be used when creating a album\r\n- `newAlbumHashes`: Got after the execution of the POST request to record the Album Id after its creation\r\n- `randomAlbumName`: Dynamically obtained using a sample from `prefixList`, a fixed string `\" album \"` and a Dynamic Variable from postman (neat!)\r\n\r\n## Oauth2 authentication\r\nIn this solution, I'll need to get manually the first pair of access and refresh token. After that, I'll refresh automatically when access token expires.\r\n\r\nRight clicking at the collection, go to Edit at the context menu, and then to the Authentication tab.\r\n\r\n![](_img/oauth_config.png)\r\n\r\nSelect `Oauth 2.0` as the type of authentication. After that, click on `Get New Access Token` to setup all info, then `Request Token`:\r\n\r\n```\r\nCallback URL: https://www.getpostman.com/oauth2/callback\r\nAuth URL: https://api.imgur.com/oauth2/authorize\r\nAccess Token URL: https://api.imgur.com/oauth2/authorize\r\n```\r\n\r\n![](_img/oauth_get_token.png)\r\n\r\nAt this moment, you're going to be requested to loggin to imgur and if everythig is ok, you're going to get a Token ready to be used.\r\n\r\n![](_img/oauth_use_token.png)\r\n\r\n\u003e Note: all requests that need to authenticate, could use `Inherit auth from parent` at its Auth tab. Although, for our purpose, choose the `Bearer Token` option, and fill the Token field with the Enviroment variable `{{accseeToken}}`. This way, every time we change the variable value, the token will be changed in every request.\r\n\r\n\u003e Note 2: Either choosing `Inherit auth from parent` or `Bearer Token` an `Authorization` entry will be added to request Header automatically.\r\n\r\n### Using the first gotten token\r\nAfter configuring and getting correctly the first pair of tokens, copy and paste its values to its respectives environment variables.\r\n\r\n![](_img/env_variables.png)\r\n\r\nTry to run some simple request to see if your basic setup is functioning\r\n\r\nTo be continued...\r\n\r\n## References\r\n\r\n- [Imgur apiDocs](https://apidocs.imgur.com/)\r\n- [How to Automate OAuth2 Token Renewal in Postman](https://medium.com/@allen.helton/how-to-automate-oauth2-token-renewal-in-postman-864420d381a0)\r\n- [Postman Sandbox API reference](https://learning.postman.com/docs/postman/scripts/postman-sandbox-api-reference/#pmsendrequest)\r\n- [How to persist an OAuth2 token (or use a refresh token) in Postman collections?](https://stackoverflow.com/questions/35070891/how-to-persist-an-oauth2-token-or-use-a-refresh-token-in-postman-collections)\r\n- [Dynamic variables in Postman](https://learning.postman.com/docs/writing-scripts/script-references/variables-list/)\r\n- [Dynamic variables](https://postman-quick-reference-guide.readthedocs.io/en/latest/dynamic-variables.html)\r\n- asd\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoamaral%2Fpostman-imgur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoamaral%2Fpostman-imgur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoamaral%2Fpostman-imgur/lists"}