Oauth
Configure OAuth providers (Google, Apple, Microsoft, Facebook, GitHub, etc.) to work with portless local dev URLs. Use when setting up OAuth redirect URIs,…
Install
Quick install
npx skills add https://github.com/vercel-labs/portless/tree/HEAD/skills/oauthnpx skills add vercel-labs/portless --skill oauth --agent claude-codenpx skills add vercel-labs/portless --skill oauth --agent cursornpx skills add vercel-labs/portless --skill oauth --agent codexnpx skills add vercel-labs/portless --skill oauth --agent opencodenpx skills add vercel-labs/portless --skill oauth --agent github-copilotnpx skills add vercel-labs/portless --skill oauth --agent windsurfMore install options
Shorthand — useful for multi-skill repos:
npx skills add vercel-labs/portless --skill oauthManual — clone the repo and drop the folder into your agent's skills directory:
git clone https://github.com/vercel-labs/portless.gitcp -r portless/skills/oauth ~/.claude/skills/oauth
Configure OAuth providers (Google, Apple, Microsoft, Facebook, GitHub, etc.) to work with portless local dev URLs. Use when setting up OAuth redirect URIs,…
oauthby vercel
Configure OAuth providers (Google, Apple, Microsoft, Facebook, GitHub, etc.) to work with portless local dev URLs. Use when setting up OAuth redirect URIs,…npx skills add https://github.com/vercel-labs/portless --skill oauthDownload ZIPGitHub
OAuth with Portless
OAuth providers validate redirect URIs against domain rules. .localhost subdomains fail on most providers because they are not in the Public Suffix List or are explicitly blocked. Portless fixes this with --tld to serve apps on real, valid domains.
The Problem
When portless uses the default .localhost TLD, OAuth providers reject redirect URIs like http://myapp.localhost:1355/callback:
Providerlocalhost.localhost subdomainsReasonGoogleAllowedRejectedNot in their bundled PSLAppleRejectedRejectedNo localhost at allMicrosoftAllowedAllowedPermissive localhost handlingFacebookAllowedVariesMust register each URI exactlyGitHubAllowedAllowedPermissive
Google and Apple are the strictest. Microsoft and GitHub are more lenient with localhost.
The Fix
Use a valid TLD so the redirect URI passes provider validation:
`portless proxy start --tld dev
portless myapp next dev
# -> https://myapp.dev
`
Any TLD in the Public Suffix List works: .dev, .app, .com, .io, etc.
Use a domain you own
Bare TLDs like .dev mean myapp.dev could collide with a real domain. Use a subdomain of a domain you control:
`portless proxy start --tld dev
portless myapp.local.yourcompany next dev
# -> https://myapp.local.yourcompany.dev
`
This ensures no outbound traffic reaches something you don't own. For teams, set a wildcard DNS record (*.local.yourcompany.dev -> 127.0.0.1) so every developer gets resolution without /etc/hosts.
Provider Setup
- Go to Google Cloud Console > Credentials
- Create or edit an OAuth 2.0 Client ID (Web application)
- Add the portless domain to Authorized JavaScript origins:
https://myapp.dev
- Add the callback to Authorized redirect URIs:
https://myapp.dev/api/auth/callback/google
Google validates domains against the Public Suffix List. The domain must end with a recognized TLD. .localhost subdomains fail this check; .dev, .app, .com, etc. all pass.
HTTPS is required for .dev and .app (HSTS-preloaded). Portless handles this automatically with --https.
Apple
Apple Sign In does not allow localhost or IP addresses at all.
- Go to Apple Developer > Certificates, Identifiers & Profiles
- Register a Services ID
- Configure Sign In with Apple, adding the portless domain as a Return URL:
https://myapp.dev/api/auth/callback/apple
The domain must be a real, publicly-resolvable domain name. Since portless maps the domain to 127.0.0.1 locally, the browser resolves it but Apple's server-side validation may require the domain to resolve publicly too. If Apple rejects the domain, add a public DNS A record pointing to 127.0.0.1 for your dev subdomain.
Microsoft (Entra / Azure AD)
- Go to Azure Portal > App registrations
- Create or edit an app registration
- Under Authentication, add a Web redirect URI:
https://myapp.dev/api/auth/callback/azure-ad
Microsoft allows http://localhost with any port for development. It also accepts .localhost subdomains in most cases. Using a custom TLD with portless is still recommended for consistency across providers.
Facebook (Meta)
- Go to Meta for Developers > App Dashboard
- Under Facebook Login > Settings, add the portless URL to Valid OAuth Redirect URIs:
https://myapp.dev/api/auth/callback/facebook
Facebook requires each redirect URI to be registered exactly (no wildcards). Strict Mode (enabled by default) enforces exact matching.
GitHub
- Go to GitHub Developer Settings > OAuth Apps
- Set Authorization callback URL:
https://myapp.dev/api/auth/callback/github
GitHub is permissive with localhost and subdomains. A custom TLD is not strictly required but keeps the setup consistent.
Auth Library Configuration
NextAuth / Auth.js
Set NEXTAUTH_URL to match the portless domain:
`NEXTAUTH_URL=https://myapp.dev
`
NextAuth uses this to construct callback URLs. Without it, callbacks may use localhost and cause a mismatch.
Passport.js
Set the callbackURL in each strategy to use the portless domain:
`new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: process.env.BASE_URL + "/auth/google/callback",
});
`
Set BASE_URL=https://myapp.dev in your environment.
Generic / Manual
Read the PORTLESS_URL environment variable that portless injects into the child process:
`const baseUrl = process.env.PORTLESS_URL || "http://localhost:3000";
const callbackUrl = `${baseUrl}/auth/callback`;
`
Troubleshooting
"redirect_uri_mismatch" or "invalid redirect URI"
The redirect URI sent during the OAuth flow doesn't match what's registered with the provider. Check:
- The provider's registered redirect URI matches the portless domain exactly (protocol, host, path)
NEXTAUTH_URLor equivalent is set to the portless URL (notlocalhost)
- The proxy is running with the correct TLD (
portless listto verify)
Provider requires HTTPS
.dev and .app TLDs are HSTS-preloaded, so browsers force HTTPS. Start the proxy:
`portless proxy start --tld dev
`
Portless defaults to HTTPS on port 443 (auto-elevates with sudo). Run portless trust to add the local CA to your system trust store and eliminate browser warnings.
Apple rejects the domain
Apple may require the domain to resolve publicly. Add a DNS A record for your dev subdomain pointing to 127.0.0.1:
`myapp.local.yourcompany.dev A 127.0.0.1
`
Or use a wildcard: *.local.yourcompany.dev A 127.0.0.1.
Callback goes to wrong URL after sign-in
The auth library is constructing the callback URL from localhost instead of the portless domain. Set the appropriate environment variable:
- NextAuth:
NEXTAUTH_URL=https://myapp.dev
- Auth.js v5:
AUTH_URL=https://myapp.dev
- Manual:
PORTLESS_URLis injected automatically; use it as the base URL
Example
See examples/google-oauth for a complete working example with Next.js + NextAuth + Google OAuth using --tld dev.
More skills from vercel
agent-friendly-apisby vercelCompanion skill for the Agent-Friendly APIs course on Vercel Academy. Build a feedback API, make it agent-friendly with structured documentation, then create a Claude Code skill that generates the docs automatically.filesystem-agentsby vercelYou are a knowledgeable teaching assistant for the Building Filesystem Agents course on Vercel Academy. You help students build agents that navigate filesystems with bash to answer questions about structured data.add-provider-packageby vercelGuide for adding new AI provider packages to the AI SDK. Use when creating a new @ai-sdk/<provider> package to integrate an AI service into the SDK.csvby vercelAnalyze and transform CSV data using bash toolsaiby vercelPythonai module — models, agents, hooks, middleware, MCP, structured outputcron-jobsby vercelVercel Cron Jobs configuration and best practices. Use when adding, editing, or debugging scheduled tasks in vercel.json.frontend-designby vercelCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts,…vercel-react-best-practicesby vercelReact and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js…
---
Source: https://github.com/vercel-labs/portless/tree/HEAD/skills/oauth
Author: vercel
Discovered via: mcpservers.org
SKILL.md source
---
name: oauth
description: Configure OAuth providers (Google, Apple, Microsoft, Facebook, GitHub, etc.) to work with portless local dev URLs. Use when setting up OAuth redirect URIs,…
---
# oauth
Configure OAuth providers (Google, Apple, Microsoft, Facebook, GitHub, etc.) to work with portless local dev URLs. Use when setting up OAuth redirect URIs,…
# oauthby vercel
Configure OAuth providers (Google, Apple, Microsoft, Facebook, GitHub, etc.) to work with portless local dev URLs. Use when setting up OAuth redirect URIs,…
`npx skills add https://github.com/vercel-labs/portless --skill oauth`Download ZIPGitHub
## OAuth with Portless
OAuth providers validate redirect URIs against domain rules. `.localhost` subdomains fail on most providers because they are not in the Public Suffix List or are explicitly blocked. Portless fixes this with `--tld` to serve apps on real, valid domains.
## The Problem
When portless uses the default `.localhost` TLD, OAuth providers reject redirect URIs like `http://myapp.localhost:1355/callback`:
Provider`localhost``.localhost` subdomainsReasonGoogleAllowedRejectedNot in their bundled PSLAppleRejectedRejectedNo localhost at allMicrosoftAllowedAllowedPermissive localhost handlingFacebookAllowedVariesMust register each URI exactlyGitHubAllowedAllowedPermissive
Google and Apple are the strictest. Microsoft and GitHub are more lenient with localhost.
## The Fix
Use a valid TLD so the redirect URI passes provider validation:
```
`portless proxy start --tld dev
portless myapp next dev
# -> https://myapp.dev
`
```
Any TLD in the Public Suffix List works: `.dev`, `.app`, `.com`, `.io`, etc.
### Use a domain you own
Bare TLDs like `.dev` mean `myapp.dev` could collide with a real domain. Use a subdomain of a domain you control:
```
`portless proxy start --tld dev
portless myapp.local.yourcompany next dev
# -> https://myapp.local.yourcompany.dev
`
```
This ensures no outbound traffic reaches something you don't own. For teams, set a wildcard DNS record (`*.local.yourcompany.dev -> 127.0.0.1`) so every developer gets resolution without `/etc/hosts`.
## Provider Setup
### Google
* Go to Google Cloud Console > Credentials
* Create or edit an OAuth 2.0 Client ID (Web application)
* Add the portless domain to Authorized JavaScript origins: `https://myapp.dev`
* Add the callback to Authorized redirect URIs: `https://myapp.dev/api/auth/callback/google`
Google validates domains against the Public Suffix List. The domain must end with a recognized TLD. `.localhost` subdomains fail this check; `.dev`, `.app`, `.com`, etc. all pass.
HTTPS is required for `.dev` and `.app` (HSTS-preloaded). Portless handles this automatically with `--https`.
### Apple
Apple Sign In does not allow `localhost` or IP addresses at all.
* Go to Apple Developer > Certificates, Identifiers & Profiles
* Register a Services ID
* Configure Sign In with Apple, adding the portless domain as a Return URL: `https://myapp.dev/api/auth/callback/apple`
The domain must be a real, publicly-resolvable domain name. Since portless maps the domain to 127.0.0.1 locally, the browser resolves it but Apple's server-side validation may require the domain to resolve publicly too. If Apple rejects the domain, add a public DNS A record pointing to 127.0.0.1 for your dev subdomain.
### Microsoft (Entra / Azure AD)
* Go to Azure Portal > App registrations
* Create or edit an app registration
* Under Authentication, add a Web redirect URI: `https://myapp.dev/api/auth/callback/azure-ad`
Microsoft allows `http://localhost` with any port for development. It also accepts `.localhost` subdomains in most cases. Using a custom TLD with portless is still recommended for consistency across providers.
### Facebook (Meta)
* Go to Meta for Developers > App Dashboard
* Under Facebook Login > Settings, add the portless URL to Valid OAuth Redirect URIs: `https://myapp.dev/api/auth/callback/facebook`
Facebook requires each redirect URI to be registered exactly (no wildcards). Strict Mode (enabled by default) enforces exact matching.
### GitHub
* Go to GitHub Developer Settings > OAuth Apps
* Set Authorization callback URL: `https://myapp.dev/api/auth/callback/github`
GitHub is permissive with localhost and subdomains. A custom TLD is not strictly required but keeps the setup consistent.
## Auth Library Configuration
### NextAuth / Auth.js
Set `NEXTAUTH_URL` to match the portless domain:
```
`NEXTAUTH_URL=https://myapp.dev
`
```
NextAuth uses this to construct callback URLs. Without it, callbacks may use `localhost` and cause a mismatch.
### Passport.js
Set the `callbackURL` in each strategy to use the portless domain:
```
`new GoogleStrategy({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: process.env.BASE_URL + "/auth/google/callback",
});
`
```
Set `BASE_URL=https://myapp.dev` in your environment.
### Generic / Manual
Read the `PORTLESS_URL` environment variable that portless injects into the child process:
```
`const baseUrl = process.env.PORTLESS_URL || "http://localhost:3000";
const callbackUrl = `${baseUrl}/auth/callback`;
`
```
## Troubleshooting
### "redirect_uri_mismatch" or "invalid redirect URI"
The redirect URI sent during the OAuth flow doesn't match what's registered with the provider. Check:
* The provider's registered redirect URI matches the portless domain exactly (protocol, host, path)
* `NEXTAUTH_URL` or equivalent is set to the portless URL (not `localhost`)
* The proxy is running with the correct TLD (`portless list` to verify)
### Provider requires HTTPS
`.dev` and `.app` TLDs are HSTS-preloaded, so browsers force HTTPS. Start the proxy:
```
`portless proxy start --tld dev
`
```
Portless defaults to HTTPS on port 443 (auto-elevates with sudo). Run `portless trust` to add the local CA to your system trust store and eliminate browser warnings.
### Apple rejects the domain
Apple may require the domain to resolve publicly. Add a DNS A record for your dev subdomain pointing to `127.0.0.1`:
```
`myapp.local.yourcompany.dev A 127.0.0.1
`
```
Or use a wildcard: `*.local.yourcompany.dev A 127.0.0.1`.
### Callback goes to wrong URL after sign-in
The auth library is constructing the callback URL from `localhost` instead of the portless domain. Set the appropriate environment variable:
* NextAuth: `NEXTAUTH_URL=https://myapp.dev`
* Auth.js v5: `AUTH_URL=https://myapp.dev`
* Manual: `PORTLESS_URL` is injected automatically; use it as the base URL
## Example
See `examples/google-oauth` for a complete working example with Next.js + NextAuth + Google OAuth using `--tld dev`.
## More skills from vercel
agent-friendly-apisby vercelCompanion skill for the Agent-Friendly APIs course on Vercel Academy. Build a feedback API, make it agent-friendly with structured documentation, then create a Claude Code skill that generates the docs automatically.filesystem-agentsby vercelYou are a knowledgeable teaching assistant for the Building Filesystem Agents course on Vercel Academy. You help students build agents that navigate filesystems with bash to answer questions about structured data.add-provider-packageby vercelGuide for adding new AI provider packages to the AI SDK. Use when creating a new @ai-sdk/<provider> package to integrate an AI service into the SDK.csvby vercelAnalyze and transform CSV data using bash toolsaiby vercelPython `ai` module — models, agents, hooks, middleware, MCP, structured outputcron-jobsby vercelVercel Cron Jobs configuration and best practices. Use when adding, editing, or debugging scheduled tasks in vercel.json.frontend-designby vercelCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts,…vercel-react-best-practicesby vercelReact and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js…
---
**Source**: https://github.com/vercel-labs/portless/tree/HEAD/skills/oauth
**Author**: vercel
**Discovered via**: mcpservers.org
Related skills 6
find-skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
appinsights-instrumentation
Guidance for instrumenting webapps with Azure Application Insights. Provides telemetry patterns, SDK setup, and configuration references. WHEN: how to instrument app, App Insights SDK, telemetry patterns, what is App Insights, Application Insights guidance, instrumentation examples, APM best practices.
azure-messaging
Troubleshoot and resolve issues with Azure Messaging SDKs for Event Hubs and Service Bus. Covers connection failures, authentication errors, message processing issues, and SDK configuration problems. WHEN: event hub SDK error, service bus SDK issue, messaging connection failure, AMQP error, event processor host issue, message lock lost, message lock expired, lock renewal, lock renewal batch, send timeout, receiver disconnected, SDK troubleshooting, azure messaging SDK, event hub consumer, ser...
azure-hosted-copilot-sdk
Build, deploy, and modify GitHub Copilot SDK apps on Azure. MANDATORY when codebase contains @github/copilot-sdk or CopilotClient in package.json. PREFER OVER azure-prepare when copilot-sdk markers detected. WHEN: copilot SDK, @github/copilot-sdk, copilot-powered app, build copilot app, prepare copilot app, add feature to copilot app, modify copilot app, BYOM, bring your own model, CopilotClient, createSession, sendAndWait, azd init copilot. DO NOT USE FOR: deploying already-prepared copilot-...
lark-event
Lark/Feishu real-time event listening / subscribing / consuming: stream events as NDJSON via `lark-cli event consume <EventKey>` (covers IM message receive, reactions, chat member changes, etc.). Use for Lark bots, real-time message processing, long-running subscribers, streaming webhook/push handlers. Supports `--max-events` / `--timeout` bounded runs and a stderr ready-marker contract — designed for AI agents running as subprocesses.
xget
Use when tasks involve Xget URL rewriting, registry/package/container/API acceleration, integrating Xget into Git, download tools, package managers, container builds, AI SDKs, CI/CD, deployment, self-hosting, or adapting commands and config from the live README `Use Cases` section into files, environments, shells, or base URLs.