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 inAuthorizationrequest 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
Authorizationvalues 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:
- Turn on Preserve log before reproducing the problem.
- Choose the export that includes sensitive data. If every
Authorizationvalue 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:
grep -o 'eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*' session.har | sort -uExpect 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):
jq -r '.log.entries[] | .request.headers[] | select(.name | ascii_downcase == "authorization") | .value' session.harTokens in JSON response bodies, such as a token endpoint returning id_token:
jq -r '.log.entries[].response.content.text | select(. != null) | split("\"") | .[] | select(test("^eyJ"))' session.harForm post bodies, where the token sits in a string like id_token=eyJ...&state=...:
jq -r '.log.entries[].request.postData.text | select(. != null)' session.harTo line a token up with the failure, list time, status and URL of every entry:
jq -r '.log.entries[] | [.startedDateTime, .response.status, .request.url] | @tsv' session.harFix 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:
TOKEN='eyJ...paste the token here...'
echo "$TOKEN" | cut -d. -f2 | tr '_-' '/+' | awk '{ while (length($0) % 4) $0 = $0 "="; print }' | base64 -DConvert exp, nbf or iat (Unix seconds) with date -r:
date -r 1700000000Web 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.
Open JSON Formatter (⌘1), choose File ▸ Open… (⌘O) and pick the
.harfile, or drop it on the editor.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')].valueFor tokens in response bodies, set the menu to jq and use the
split/testfilter from Fix 2. Turn on Raw to drop the quotes.Alternatively switch the output to Tree, press ⌘F with the tree focused, and search for
authorization.Copy the token and press ⌘4 to open JWT Decoder. Paste it into Token; a
Bearerprefix is accepted.Read Payload and the badge: Expired, Not Yet Valid, Valid or No Expiry.
iat,nbfandexpshow 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.
| Method | Good for | Limit |
|---|---|---|
grep | Listing every JWT in seconds | Doesn't say which request carried it |
jq | Exact header, body and status lookups | You decode and convert times yourself |
| Web decoder | Quick decode, no install | You paste a live token into a page |
| Bytepliers | Open, filter, decode with expiry badges | Mac only; part of the MacSuite bundle |
What to check in the token
expagainst the request time. Compare it with thestartedDateTimeof the entry that carried the token. Already expired on arrival points to slow redirects or a stale cached token.iatandnbfagainststartedDateTime. That timestamp comes from the user's browser clock. Ifnbfis later than it, oriatis 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,iatand 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,audandisswith the app's settings. - You have a HAR from a working user to compare.
If nothing works
- No
eyJstrings at all. Sign-in likely failed before a token was issued. List failures withjq -r '.log.entries[] | select(.response.status >= 400) | .request.url' session.har, then read those bodies forerrororerror_description. - Authorization values empty. Re-export with sensitive data included.
- Token came back in the URL fragment. If the browser recorded the redirect's
Locationheader,grepfinds it there; otherwise look at later API calls'Authorizationheader. - Body stored as base64. When
contenthas"encoding": "base64", decodetextfirst (the Base64 tool, ⌘2, in Bytepliers). - Value won't decode. A string that doesn't start with
eyJor 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
grepandjqfor 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:
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.