Skip to content

feat: Sign in with AssemblyAI (PE-2657) - #253

Closed
damafeez wants to merge 2 commits into
mainfrom
aawoyemi/feat/PE-2657/sign-in-with-assemblyai
Closed

damafeez wants to merge 2 commits into
mainfrom
aawoyemi/feat/PE-2657/sign-in-with-assemblyai

Conversation

@damafeez

@damafeez damafeez commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What & why

Adds "Sign in with AssemblyAI" as an alternative to pasting a key (PE-2657, part of the Agent OAuth epic PE-2644). The member signs in and approves Blurt on AssemblyAI's consent page. Blurt then trades the access token for the connection's own API key and stores it where a pasted key goes, so dictation, the press gate and Settings read it unchanged.

  • Flow: authorization code with PKCE, as a public client (no secret). The browser part runs in ASWebAuthenticationSession, with redirect com.assemblyai.blurt://oauth/callback, which the session catches without a registered URL handler.
  • Renewal: at launch, then checked hourly. It refreshes and re-exchanges at most once a day, or within two days of the key's expiry, keeping a rotated refresh token. If the server refuses, the connection was ended elsewhere, so the key and session are cleared. If the server can't be reached, nothing changes.
  • Sign Out: ends the connection server-side (POST /api/v2/oauth/api-key/revoke), then clears it on the Mac. If the server can't confirm, everything stays in place and the user can retry.
  • Off by default: a build turns it on with four Info.plist values (BLURT_OAUTH_* in App/Blurt/project.yml). Debug points at the Stytch test project and the staging dashboard and site. Release is empty, so shipping builds still offer only the paste-a-key path.

AGENTS.md (Settings, persistence) describes the design. The AssemblyAI library gains OAuthAuthorization and OAuthClient; Blurt's policy (storage, renewal, wording) stays in the engine.

Draft because a sandbox key can't dictate yet: Blurt always calls production dictation. A follow-up commit adds BLURT_OAUTH_DICTATION_ORIGIN, so a signed-in Debug build dictates against sandbox.

How it was tested

  • scripts/check.sh passes locally: engine coverage 89.06%, iOS check green, swift-format and swiftlint clean
  • I read AGENTS.md and this doesn't reintroduce anything deliberately removed. There are no new dependencies (CryptoKit is a system framework), and no new app package.
  • Docs updated: AGENTS.md and Sources/AssemblyAI/README.md

Unit tests:

  • PKCE against RFC 7636's worked example.
  • Callback checks: wrong state, decline, error, missing code.
  • Token, exchange and revoke status mapping.
  • Renewal: due rules, rotated tokens, refused or unreachable server.
  • Sign-out: unconfirmed, already ended, and a build without sign-in configured.
  • An unreadable Keychain item.
  • Two race tests: a sign-out or reset during a renewal must win. Both fail with the guard removed.

End to end against sandbox (ad-hoc Debug build, staging dashboard, sandbox000 AMS):

  • Sign-in completes and the row shows "Signed in as …".
  • Microphone and Accessibility are granted.
  • Dictation gets a 401, as expected with a sandbox key against production dictation; this is the follow-up above.

Reviewed by the repo's three agents: swift6-concurrency, macos-hig and cleanup. Their findings are applied.

Found along the way, fixed elsewhere:

  • DeepLearning#22294: AMS rejected every real access token, because it didn't accept their issuer.
  • frontend#1453: a native redirect showed "You'll be redirected to oauth".
  • frontend#1455: a verified seal on first-party apps.

🤖 Generated with Claude Code

damafeez and others added 2 commits October 20, 2026 12:38
The alternative to pasting a key: the member signs in and approves Blurt
on AssemblyAI's consent page (authorization code + PKCE, public client,
ASWebAuthenticationSession, redirect com.assemblyai.blurt://oauth/callback),
and Blurt trades the access token for the connection's own API key, which
it stores where a pasted key goes.

- AssemblyAI library: OAuthAuthorization (PKCE, consent URL, callback
  check) and OAuthClient (token endpoint, POST /api/v2/oauth/api-key and
  /revoke). Refused calls log the route, status and server reason, never
  a token.
- Engine: AssemblyAIAccount (sign-in, renewal, sign-out), SignInSession
  in its own Keychain item with a read that keeps "none" apart from
  "unavailable", CredentialRows (which rows show), runRenewal (launch,
  then hourly; renews daily or within two days of key expiry). A
  generation counter keeps a renewal from undoing a sign-out or reset.
- Shell: AccountSignIn (the web session) and AccountRowView ("Sign In
  with AssemblyAI…" / "Signed in as …" + Sign Out; recoverable failures
  inline, Keychain faults as alerts). The reset clears the session too.
- Off unless a build sets BLURT_OAUTH_CLIENT_ID, _TOKEN_URL,
  _AUTHORIZE_URL and _API_ORIGIN (https, or http to loopback for a local
  dashboard). Debug points at the Stytch test project and staging;
  Release stays empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A key minted by a sandbox sign-in only works against that sandbox's
dictation host, and dictation always went to production, so a signed-in
Debug build got a 401 on every dictation.

- BLURT_OAUTH_DICTATION_ORIGIN (optional): the dictation host the sign-in
  mints keys for. Debug: https://dictation.sandbox000.assemblyai-labs.com.
  Release: empty, i.e. production.
- AssemblyAIAccount keeps a DictationOrigin (Mutex) current as it signs in
  and out; AssemblyAITranscriber reads it at every request and warm-up.
  A pasted key, or no origin configured, stays on production.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@damafeez damafeez mentioned this pull request Oct 20, 2026
3 tasks done
@damafeez

Copy link
Copy Markdown
Contributor Author

Superseded by #254.

@damafeez damafeez closed this Oct 20, 2026
@damafeez
damafeez deleted the aawoyemi/feat/PE-2657/sign-in-with-assemblyai branch October 20, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant