Skip to content
86% off$349 $48.86code BF2026

Guides

Extract a JWT Token From a HAR File (Azure AD B2C Sign-In)

Find the JWT in a HAR file with grep, jq or Bytepliers, decode it, and check exp, nbf, aud and iss to see why Azure AD B2C users loop back to sign-in.

GuideUpdated 7 min read

On this page

You have HAR files from the few users who can't finish sign-in, and you need to see the token they were issued. You've done it before but can't remember how. The token is in the file, just buried: a sign-in flow produces dozens of entries under log.entries, and the JWT may sit in a request header, a form post body or a response body.

Why the token is hard to find

  • Many tokens, many places. A B2C sign-in can involve an id_token, an access token and others. They appear in Authorization request headers, in token endpoint responses, or in form post bodies when the response mode is a form post.
  • The browser may have removed it. Recent Chrome versions can leave cookies and Authorization values out of exported HAR files unless you choose an export that includes sensitive data. The exact menu label depends on the browser version.
  • Redirects clear the log. Without Preserve log, earlier requests disappear during sign-in redirects.
  • URL fragments aren't sent. A token returned after # in a URL never reaches a server, so later request URLs won't contain it.

Capture a HAR that contains the token

Ask the affected user to export from the browser's Network panel (Chrome DevTools has an export button in the panel toolbar). Two details matter:

  1. Turn on Preserve log before reproducing the problem.
  2. Choose the export that includes sensitive data. If every Authorization value in the file is empty or redacted, the token was removed at export and you need a new HAR.

Fix 1: list every JWT with grep

A JWT is three base64url segments separated by dots, and the first starts with eyJ (it encodes {"). This only reads the file:

bash
grep -o 'eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*' session.har | sort -u

Expect several results. grep can't tell you which request carried each one.

Fix 2: see which request carried it with jq

If jq --version fails, install it with Homebrew (brew install jq).

Authorization headers on requests (lowercasing the name matches both spellings):

bash
jq -r '.log.entries[] | .request.headers[] | select(.name | ascii_downcase == "authorization") | .value' session.har

Tokens in JSON response bodies, such as a token endpoint returning id_token:

bash
jq -r '.log.entries[].response.content.text | select(. != null) | split("\"") | .[] | select(test("^eyJ"))' session.har

Form post bodies, where the token sits in a string like id_token=eyJ...&state=...:

bash
jq -r '.log.entries[].request.postData.text | select(. != null)' session.har

To line a token up with the failure, list time, status and URL of every entry:

bash
jq -r '.log.entries[] | [.startedDateTime, .response.status, .request.url] | @tsv' session.har

Fix 3: decode the middle segment in Terminal

The payload is the part between the two dots. Base64url drops = padding and uses - and _, so convert and pad before decoding:

bash
TOKEN='eyJ...paste the token here...'
echo "$TOKEN" | cut -d. -f2 | tr '_-' '/+' | awk '{ while (length($0) % 4) $0 = $0 "="; print }' | base64 -D

Convert exp, nbf or iat (Unix seconds) with date -r:

bash
date -r 1700000000

Web decoders such as jwt.io exist, and Auth0 staff have said decoding there happens locally in the browser. Still, you'd be pasting a live user token into a web page, which some teams forbid. For other Mac-side options see how to decode a JWT on Mac.

Fix 4: open, filter and decode in Bytepliers

Bytepliers opens a HAR directly in its JSON Formatter, filters it with jq or JSONPath, and decodes the token with expiry badges. It works offline and needs macOS 14 or later.

  1. Open JSON Formatter (⌘1), choose File ▸ Open… (⌘O) and pick the .har file, or drop it on the editor.

  2. For a precise answer, use the filter bar under the output. Set the language menu to JSONPath and enter:

    $.log.entries[*].request.headers[?(@.name=='authorization' || @.name=='Authorization')].value

  3. For tokens in response bodies, set the menu to jq and use the split/test filter from Fix 2. Turn on Raw to drop the quotes.

  4. Alternatively switch the output to Tree, press ⌘F with the tree focused, and search for authorization.

  5. Copy the token and press ⌘4 to open JWT Decoder. Paste it into Token; a Bearer prefix is accepted.

  6. Read Payload and the badge: Expired, Not Yet Valid, Valid or No Expiry. iat, nbf and exp show relative times.

To learn which entry a value came from, paste the HAR into the JSONPath tool (Inspect group) with the same expression. The Matches list shows paths like $['log']['entries'][12]...; then run jq '.log.entries[12] | .startedDateTime, .request.url' session.har. Most tools other than JSON Formatter refuse input over 2 MB, so use the filter bar for big files.

Bytepliers doesn't record JWT Decoder input in its history, nor any text containing a JWT, unless you turn on Also record inputs that look like secrets. Tokens copied out are marked concealed for clipboard managers that honor that convention, and keys you paste for verification stay in memory only. The filter bar and tree are covered in the JSON Formatter docs. Bytepliers is part of MacSuite; you can try it free for 7 days.

MethodGood forLimit
grepListing every JWT in secondsDoesn't say which request carried it
jqExact header, body and status lookupsYou decode and convert times yourself
Web decoderQuick decode, no installYou paste a live token into a page
BytepliersOpen, filter, decode with expiry badgesMac only; part of the MacSuite bundle

What to check in the token

  • exp against the request time. Compare it with the startedDateTime of the entry that carried the token. Already expired on arrival points to slow redirects or a stale cached token.
  • iat and nbf against startedDateTime. That timestamp comes from the user's browser clock. If nbf is later than it, or iat is minutes after it, suspect a wrong device clock, especially when only some users fail.
  • aud. It should match the client ID your app validates. A mismatch means the token was issued for another app registration.
  • iss. It should match the issuer your app trusts. A token from the wrong tenant or policy endpoint is rejected even if valid.
  • Missing claims. If your app requires an email, role or custom attribute and the payload lacks it, a valid token can still be refused.
  • A working user for comparison. Paste both payloads into JSON Compare, which ignores key order and lists changes. Expect exp, iat and user identifiers to differ; look for anything else.

To check the signature, JWT Decoder's Signature pane accepts a secret, or a public key as PEM, JWK or JWK Set, and reports "Signature verified" or "Invalid signature". You supply the key; the app doesn't fetch it.

Checklist before you try again

  • The HAR was exported with Preserve log on.
  • Sensitive data was included in the export.
  • You are decoding the token from the failing request, not a later one.
  • You compared exp, nbf, aud and iss with the app's settings.
  • You have a HAR from a working user to compare.

If nothing works

  • No eyJ strings at all. Sign-in likely failed before a token was issued. List failures with jq -r '.log.entries[] | select(.response.status >= 400) | .request.url' session.har, then read those bodies for error or error_description.
  • Authorization values empty. Re-export with sensitive data included.
  • Token came back in the URL fragment. If the browser recorded the redirect's Location header, grep finds it there; otherwise look at later API calls' Authorization header.
  • Body stored as base64. When content has "encoding": "base64", decode text first (the Base64 tool, ⌘2, in Bytepliers).
  • Value won't decode. A string that doesn't start with eyJ or lacks two dots is opaque or encrypted, not readable claims.
  • Huge file. JSON Formatter accepts up to 64 MB; Bytepliers asks before opening files over 50 MB and refuses over 256 MB. Use grep and jq for bigger ones.
  • jq filter errors in the filter bar. Its jq covers select, test, split, | and .[] but not every feature. Use JSONPath or run it in Terminal.

If the token looks correct and users still loop, contact Microsoft support for Azure AD B2C with details like this:

text
Subject: Azure AD B2C users returned to sign-in after authentication

Tenant and policy: your tenant name, your user flow name
Affected users: about 1-2% (HAR files attached for 3 users)
Observed: id_token issued, user returned to sign-in
Token checks: exp/nbf/iat consistent with request time; aud = our client ID; iss = our policy endpoint
Timestamps (UTC): first failure time, second failure time
Steps tried: cleared cache, new HAR with sensitive data included
Question: what could cause B2C or our app to reject this token?

Strip or revoke tokens before sharing a HAR outside your team.

Common questions

Is it safe to share a HAR file?

Not as-is. It can contain live tokens and cookies. Remove them or wait until the tokens expire, and share only with people who need them.

Can I find the token in the Network tab without exporting?

Yes: select the request, open Headers, and read Authorization. The HAR is useful when you can't watch the user's session yourself.

Why does the id_token differ from the access token?

They have different audiences and purposes. The id_token describes the signed-in user to your app; the access token is meant for an API. Check aud on each.

Does decoding prove the token is valid?

No. Decoding only reads the claims. Validity needs the signature checked against the right key, plus exp, nbf, aud and iss.

Every app.
One purchase.