← All posts

Start the Gmail OAuth review on day one

· 6 min read

Some of the longest delays in a software project have nothing to do with code. They come from an approval that sits outside the team: a store review, a security assessment, a vendor sign-off. The only defence is to find those items in the first week and start them before anything else.

We saw this on the Receipt & Purchase Tracking Platform, built for a US Apple Authorized Reseller that files tax refunds against thousands of device purchases. The goal sounded simple: read receipts from an inbox and turn them into clean, per-device records. The hard part was getting permission to read that inbox at all.

The problem: receipts in an inbox, totals that could not be trusted

Receipts arrived by email and manual download. One receipt could carry anywhere from 2 to more than 40 devices. Tax rates changed by store location. Returns and duplicate store emails were corrupting the refund totals. The client was using a bloated general-purpose platform for this and needed a tool that did only the workflows they actually used.

Why Gmail access is not a normal API key

Reading a user's mail through the Gmail API falls under what Google calls restricted scopes. Google's documentation says apps that use these scopes go through a verification process, and that process can take several weeks. According to Google's help centre, these apps also need a security assessment from an independent third-party assessor, repeated every 12 months. That assessment is the last step, after every other verification requirement is complete.

Google's own pages are not fully consistent about exactly when the assessment applies. Some wording ties it to apps that store or transmit restricted data on a server. If your architecture decides whether you need it, confirm with Google or an assessor before you commit to the design, not after.

What we did first

Before writing a parser or a dashboard, we started the Google review. The client had a September launch, and a process measured in weeks could not run in parallel with a build that was nearly finished. It had to be on the critical path from day one. The engineering work, which was mostly in our control, fitted into the time the review needed.

What we chose not to do

Apple publishes no consumer order API. The tempting shortcut is to log in to customer accounts and scrape order pages. That violates Apple's terms and breaks on two-factor authentication, so we documented it as not technically feasible before the contract was signed. The same no-list covered scanned-image parsing, a full record-editing interface with an audit trail, historical data migration, and four unused tabs from the old platform.

What we built

  • Read-only Gmail sync on one inbox, picking out Apple Store senders and grouping by location.
  • A parser that explodes each receipt into per-device lines: model, colour, storage, IMEI, serial, price, tax, location and time.
  • A tax table by store region that extracts the tax printed on the receipt instead of recalculating it, and flags mismatches.
  • IMEI as the universal key, used for duplicate detection and for matching credit receipts to returns.
  • A review queue for flagged rows, so mismatches never silently enter the refund total.
  • CSV export at one row per device, with pre-tax and tax separated.

Why IMEI as the key mattered

Once every device line carries an IMEI, three hard problems collapse into one. Duplicate store emails match on the same IMEI. A credit receipt for a return finds the original purchase by IMEI. A PDF uploaded by hand from Apple.com flows into the same model, so there is no second reconciliation step. Choosing the right key early removed whole categories of edge cases.

What to take from this

  • List every approval you depend on, and start the slowest one first.
  • Ask for the narrowest permission that does the job. Read-only was enough here.
  • Write down the integrations that are not possible, with the reason, before the contract.
  • Pick one stable identifier for your records before you design the parser.

If your product depends on a third-party approval or a restricted API, bring it to the scope call. We will tell you early what is on the critical path.

Read the case study: Receipt & Purchase Tracking Platform.

Related: our approach, projects or book a scope call.