playwright-oauth-code-capture

Intercept localhost redirects with Playwright page.route to capture OAuth authorization codes.

Updated Jan 24, 2026
One-click install
npx skills add https://github.com/strataga/claude-setup --skill playwright-oauth-code-capture
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-oauth-code-capture
Source: https://github.com/strataga/claude-setup/tree/main/skills/playwright-oauth-code-capture
Command: npx skills add https://github.com/strataga/claude-setup --skill playwright-oauth-code-capture

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Capture OAuth authorization codes during Playwright automation when redirects to localhost fail and the code would otherwise be lost.

Core Features & Use Cases

  • Intercept localhost redirects with Playwright's page.route to capture the full redirect URL before the failure.
  • Extract the code parameter from the captured URL for token exchange with the OAuth provider.
  • Works across desktop-style OAuth flows (redirect_uri=http://localhost) and common providers such as Google and GitHub.

Quick Start

Run Playwright automation with a route interception registered before triggering the OAuth flow, then capture and extract the code from the redirected URL.

Frequently Asked Questions about playwright-oauth-code-capture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I capture an OAuth authorization code in Playwright when the localhost redirect fails?

To capture an OAuth authorization code in Playwright when localhost redirects fail, register a page.route interception before triggering the flow to read the full redirect URL before the request aborts, enabling extraction of the code parameter.

Why does my Playwright OAuth flow lose the authorization code on localhost?

Your Playwright OAuth flow loses the authorization code because desktop-style redirect_uri=http://localhost requests fail without a local server, aborting the navigation before the code parameter can be read.

Does this OAuth code capture method work with Google and GitHub providers?

Yes, this OAuth code capture method works with Google and GitHub providers, intercepting their desktop-style OAuth flows that use redirect_uri=http://localhost to extract the authorization code for token exchange.

What's the best way to get an OAuth token from a localhost redirect in automation testing?

The best way to get an OAuth token from a localhost redirect in automation testing is intercepting the request with Playwright's page.route to capture the URL and extract the code parameter for token exchange.

Do I need a local server running to capture OAuth codes during Playwright automation?

No, you do not need a local server running to capture OAuth codes during Playwright automation, because page.route interception reads the full redirect URL before the localhost request fails and the code is lost.