Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Build password recovery as two separate API operations: one requests a reset link, and the other validates its token before changing a password. The request endpoint should return the same public response whether an email is registered or not; the token must be securely generated, tied to one account, expire, and become unusable after a successful reset. Postman can then exercise normal, invalid, expired, and reused-token cases against your local or test API.

How the reset flow should work

Password recovery proves control of a verified side channel, usually the email address already associated with an account. It should not change account state merely because someone submitted an email address.

Request a reset

  1. Accept an email address or other account identifier and validate its format.
  2. Apply rate limits, including controls against repeated requests and automated abuse.
  3. If the identifier matches an account, generate a cryptographically secure reset token, associate it with that account, store it securely, and deliver a reset link through the verified contact channel. Treat delivery as an asynchronous side effect where appropriate.
  4. Return the same public message and response shape whether or not the account exists. OWASP’s Forgot Password Cheat Sheet advises: “Return a consistent message for both existent and non-existent accounts.” Make response timing reasonably consistent as well, without relying on exact millisecond equality.

Consume the token

  1. Accept the reset token and proposed new password.
  2. Verify that the token is valid, unexpired, unused, and bound to the intended account.
  3. Apply the application’s existing password policy. If the API requires password confirmation, validate it before making a change.
  4. Safely update the stored password, invalidate the used token and any outstanding reset links as appropriate, notify the account owner, and require ordinary sign-in.

These controls follow the OWASP Forgot Password Cheat Sheet. OWASP describes several recovery approaches, including URL tokens and codes; an email URL token is a practical example, not a universal requirement. The guidance does not prescribe one token lifetime or storage mechanism for every application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect reset links and account state

  • Use HTTPS for reset links. Build their URLs from a configured, trusted host rather than blindly using the incoming request’s Host header.
  • Limit token guesses and reset-request volume. Use a token with sufficient length and cryptographic randomness; avoid putting account details into the token itself.
  • Set Referrer-Policy: no-referrer on the reset page to reduce the chance that a token in the URL is disclosed through referrer data.
  • After a successful reset, notify the user and invalidate sessions and other outstanding reset links as appropriate. Do not automatically sign the user in just because the password changed.

Flask’s security guidance also covers deployment host restrictions and browser protections. If the application uses cookies for authenticated state-changing requests, use CSRF defenses and configure cookies with Secure, HttpOnly, and an appropriate SameSite value. These measures complement, but do not replace, reset-token validation.

Choose custom Flask code or Flask-Security

A custom implementation gives you control over persistence, endpoints, token handling, and integration with your password policy, but you must build and maintain each security control. Flask-Security is an alternative when its recovery flow fits your application; it is not proof that its routes match every API design.

Consideration Custom flow Flask-Security
Token generation and persistence You design and maintain them to suit your application. Provided as part of the extension’s recovery flow; check the configuration for the deployed version.
Expiration and invalidation You define and enforce expiration, single use, and invalidation behavior. Supports configurable expiration. Its documented default reset behavior updates fs_uniquifier to invalidate existing sessions and authentication tokens.
Endpoint and user experience fit You can shape a JSON API and its responses around your contract. Confirm that the extension’s flow and routes fit your API and user experience.
Email delivery and password policy You integrate delivery and enforce your application’s established policy. Confirm how its flow integrates with your delivery setup and policy.

Flask-Security’s features page is labeled version 5.9.0 and documents password recovery with email links, configurable expiry, and a redirect to login after reset. Its stable changelog, labeled 5.9.1, records version-specific changes: expired links require a new request, automatic login after reset is disabled by default, and identity information is omitted from redirect query parameters. The changelog also documents a change to the default SECURITY_RESET_PASSWORD_WITHIN value from five days to one day. These are library defaults and history, not universal security requirements; verify the installed package version and effective configuration. See the Flask-Security features documentation and stable changelog.

Set up a Postman collection

Use a collection to keep the requests and assertions for your API together. Set a local environment variable such as base_url to your development server’s base URL, then use it in each request. Keep test accounts and reset tokens isolated to a local or test environment; do not put real passwords or live reset tokens in shared examples or committed collection data.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Create a request named Request password reset. Set its method, URL, headers, and JSON body to match your API contract. For example, an API might accept an email field, but the actual route and field names depend on your implementation.
  2. Create a request named Complete password reset with the token and new password fields your API expects. Keep any test token in a controlled test environment rather than a shared collection.
  3. Save both requests in the collection. Postman supports reusable request definitions, variables, and post-response scripts; use those scripts to assert the response contract and expected status.
  4. Use Postman Vault for sensitive values that need to be reused, and avoid sharing or committing secret values.

Postman documents request setup in request basics, reusable data in variables, and response assertions in test scripts.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Test the API behavior in Postman

Write assertions for your own API contract rather than assuming these illustrative cases use particular route names, status codes, or field names. Post-response scripts can check status, response structure, and expected values.

Case What to verify
Known and unknown email Both responses have the same public message and response shape. Do not require exact millisecond timing equality.
Malformed email or missing input The API rejects invalid input according to its validation contract and does not send a reset link.
Repeated reset requests Rate limits take effect and responses do not reveal whether an account exists.
Valid token and acceptable password The API reports success according to its contract; then sign in through the normal login flow using the new password.
Invalid, expired, or previously used token The API rejects the attempt and leaves the password unchanged.
Invalid password or missing confirmation If confirmation is part of the API, or the password fails policy, validation fails without changing the password.
Token reuse after success The token that completed a reset is rejected on a subsequent attempt.
Existing session after reset If the application supports sessions, verify its intended invalidation behavior.

These are recommended test cases, not results from a live API. The Postman documentation explains how to add assertions, but the exact expected statuses and response bodies must come from your implementation’s contract.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.