Google Antigravity Directory

The #1 directory for Google Antigravity prompts, rules, workflows & MCP servers. Optimized for Gemini 3 agentic development.

Resources

PromptsMCP ServersAntigravity RulesGEMINI.md GuideBest Practices

Company

Submit PromptAntigravityAI.directory

Popular Prompts

Next.js 14 App RouterReact TypeScriptTypeScript AdvancedFastAPI GuideDocker Best Practices

Legal

Privacy PolicyTerms of ServiceContact Us
Featured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver ToolsFeatured on FazierFeatured on WayfindioAntigravity AI - Featured on Startup FameFeatured on Wired BusinessFeatured on Twelve ToolsListed on Turbo0Featured on findly.toolsFeatured on Aura++That App ShowAI ToolzShinyLaunchMillion Dot HomepageSolver Tools

© 2026 Antigravity AI Directory. All rights reserved.

The #1 directory for Google Antigravity IDE

This website is not affiliated with, endorsed by, or associated with Google LLC. "Google" and "Gemini" are trademarks of Google LLC.

Antigravity AI Directory
PromptsMCPBest PracticesUse CasesLearn
Home
Prompts
OAuth SSO Implementation Patterns

OAuth SSO Implementation Patterns

Implement enterprise SSO with OAuth providers in Google Antigravity applications.

ssooauthauthenticationsecurity
by antigravity-team
⭐0Stars
.antigravity
# OAuth SSO Patterns for Google Antigravity

Implement enterprise-grade Single Sign-On with OAuth 2.0 and social providers.

## OAuth Configuration

```typescript
// lib/supabase/auth.ts
import { createClient } from "@/lib/supabase/client";

export type OAuthProvider = "google" | "github" | "azure";

export async function signInWithOAuth(provider: OAuthProvider, redirectTo?: string) {
    const supabase = createClient();
    const { data, error } = await supabase.auth.signInWithOAuth({
        provider,
        options: {
            redirectTo: redirectTo || `${window.location.origin}/auth/callback`,
            scopes: provider === "google" ? "openid email profile" : undefined,
        },
    });
    if (error) throw error;
    return data;
}
```

## Callback Handler

```typescript
// app/auth/callback/route.ts
import { NextRequest, NextResponse } from "next/server";
import { createClient } from "@/lib/supabase/server";

export async function GET(request: NextRequest) {
    const { searchParams, origin } = new URL(request.url);
    const code = searchParams.get("code");
    const next = searchParams.get("next") || "/";

    if (code) {
        const supabase = createClient();
        const { data, error } = await supabase.auth.exchangeCodeForSession(code);

        if (error) {
            return NextResponse.redirect(`${origin}/auth/error?message=${encodeURIComponent(error.message)}`);
        }

        if (data.user) {
            const { data: existing } = await supabase.from("profiles").select("id").eq("id", data.user.id).single();
            if (!existing) {
                await supabase.from("profiles").insert({
                    id: data.user.id,
                    email: data.user.email,
                    full_name: data.user.user_metadata.full_name || data.user.user_metadata.name,
                    avatar_url: data.user.user_metadata.avatar_url,
                });
            }
        }
        return NextResponse.redirect(`${origin}${next}`);
    }

    return NextResponse.redirect(`${origin}/auth/error`);
}
```

## Social Login Buttons

```typescript
// components/auth/SocialLoginButtons.tsx
"use client";

import { useState } from "react";
import { signInWithOAuth, OAuthProvider } from "@/lib/supabase/auth";

const providers: { id: OAuthProvider; name: string; icon: string; color: string }[] = [
    { id: "google", name: "Google", icon: "G", color: "#4285f4" },
    { id: "github", name: "GitHub", icon: "GH", color: "#333" },
    { id: "azure", name: "Microsoft", icon: "M", color: "#00a4ef" },
];

export function SocialLoginButtons({ redirectTo }: { redirectTo?: string }) {
    const [loading, setLoading] = useState<OAuthProvider | null>(null);

    const handleLogin = async (provider: OAuthProvider) => {
        setLoading(provider);
        try {
            await signInWithOAuth(provider, redirectTo);
        } catch (error) {
            console.error(error);
            setLoading(null);
        }
    };

    return (
        <div className="social-buttons">
            {providers.map((p) => (
                <button key={p.id} onClick={() => handleLogin(p.id)} disabled={loading !== null} style={{ backgroundColor: p.color }}>
                    <span>{p.icon}</span>
                    <span>{loading === p.id ? "Connecting..." : `Continue with ${p.name}`}</span>
                </button>
            ))}
        </div>
    );
}
```

## Enterprise SSO Check

```typescript
// lib/sso/enterprise.ts
import { createClient } from "@/lib/supabase/server";

export async function getSSOProviderForDomain(domain: string) {
    const supabase = createClient();
    const { data } = await supabase.from("sso_providers").select("*").contains("domains", [domain]).eq("enabled", true).single();
    return data;
}
```

## Enterprise Login Component

```typescript
// components/auth/EnterpriseLogin.tsx
"use client";

import { useState } from "react";
import { getSSOProviderForDomain } from "@/lib/sso/enterprise";

export function EnterpriseLogin() {
    const [email, setEmail] = useState("");
    const [loading, setLoading] = useState(false);
    const [error, setError] = useState<string | null>(null);

    const handleSubmit = async (e: React.FormEvent) => {
        e.preventDefault();
        setLoading(true);
        setError(null);

        try {
            const domain = email.split("@")[1];
            const ssoProvider = await getSSOProviderForDomain(domain);

            if (ssoProvider) {
                const returnUrl = encodeURIComponent(`${window.location.origin}/auth/sso/callback`);
                window.location.href = `${ssoProvider.sso_url}?RelayState=${returnUrl}`;
            } else {
                setError("No SSO configured for this domain.");
            }
        } catch (err) {
            setError("Failed to check SSO configuration");
        } finally {
            setLoading(false);
        }
    };

    return (
        <form onSubmit={handleSubmit}>
            <h2>Enterprise Login</h2>
            <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="Work email" required />
            <button type="submit" disabled={loading}>{loading ? "Checking..." : "Continue"}</button>
            {error && <p className="error">{error}</p>}
        </form>
    );
}
```

## Best Practices

1. **State Parameter**: Use state parameter to prevent CSRF
2. **PKCE Flow**: Use PKCE for public clients
3. **Token Storage**: Store tokens securely in httpOnly cookies
4. **Session Timeout**: Implement proper session management
5. **Audit Logging**: Log all authentication events

When to Use This Prompt

This sso prompt is ideal for developers working on:

  • sso applications requiring modern best practices and optimal performance
  • Projects that need production-ready sso code with proper error handling
  • Teams looking to standardize their sso development workflow
  • Developers wanting to learn industry-standard sso patterns and techniques

By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their sso implementations.

How to Use

  1. Copy the prompt - Click the copy button above to copy the entire prompt to your clipboard
  2. Paste into your AI assistant - Use with Claude, ChatGPT, Cursor, or any AI coding tool
  3. Customize as needed - Adjust the prompt based on your specific requirements
  4. Review the output - Always review generated code for security and correctness
💡 Pro Tip: For best results, provide context about your project structure and any specific constraints or preferences you have.

Best Practices

  • ✓ Always review generated code for security vulnerabilities before deploying
  • ✓ Test the sso code in a development environment first
  • ✓ Customize the prompt output to match your project's coding standards
  • ✓ Keep your AI assistant's context window in mind for complex requirements
  • ✓ Version control your prompts alongside your code for reproducibility

Frequently Asked Questions

Can I use this sso prompt commercially?

Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.

Which AI assistants work best with this prompt?

This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.

How do I customize this prompt for my specific needs?

You can modify the prompt by adding specific requirements, constraints, or preferences. For sso projects, consider mentioning your framework version, coding style, and any specific libraries you're using.

Related Prompts

💬 Comments

Loading comments...