Convex.Client.Extensions.Clerk.Godot 3.0.0-alpha

This is a prerelease version of Convex.Client.Extensions.Clerk.Godot.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Convex.Client.Extensions.Clerk.Godot --version 3.0.0-alpha
                    
NuGet\Install-Package Convex.Client.Extensions.Clerk.Godot -Version 3.0.0-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Convex.Client.Extensions.Clerk.Godot" Version="3.0.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Convex.Client.Extensions.Clerk.Godot" Version="3.0.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Convex.Client.Extensions.Clerk.Godot" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Convex.Client.Extensions.Clerk.Godot --version 3.0.0-alpha
                    
#r "nuget: Convex.Client.Extensions.Clerk.Godot, 3.0.0-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Convex.Client.Extensions.Clerk.Godot@3.0.0-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Convex.Client.Extensions.Clerk.Godot&version=3.0.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Convex.Client.Extensions.Clerk.Godot&version=3.0.0-alpha&prerelease
                    
Install as a Cake Tool

Convex.Client.Extensions.Clerk.Godot

Godot desktop application support for Convex Clerk authentication. Provides device code flow with manual token entry fallback for desktop applications.

Features

  • ✅ Device Code Flow - OAuth2 device code flow for desktop authentication
  • ✅ Manual Token Entry - Fallback option for manual token paste
  • ✅ Godot UI Dialog - Built-in authentication dialog for Godot
  • ✅ Token Caching - Automatic token caching and refresh
  • ✅ Easy Integration - Simple extension methods for setup

Installation

dotnet add package Convex.Client.Extensions.Clerk.Godot

Or add a project reference:

<ProjectReference Include="..\..\src\Convex.Client.Extensions.Clerk.Godot\Convex.Client.Extensions.Clerk.Godot.csproj" />

Quick Start

1. Add Configuration

Add your Clerk configuration to appsettings.json:

{
  "Clerk": {
    "PublishableKey": "pk_test_YOUR_CLERK_PUBLISHABLE_KEY_HERE",
    "TokenTemplate": "convex"
  },
  "Convex": {
    "DeploymentUrl": "https://your-deployment.convex.cloud"
  }
}

2. Initialize in ConvexManager

In your ConvexManager.cs:

using Convex.Client.Extensions.Clerk;
using Convex.Client.Extensions.Clerk.Godot;

public partial class ConvexManager : Node
{
    private GodotClerkTokenService? _clerkTokenService;
    private ClerkAuthDialog? _authDialog;

    public override void _Ready()
    {
        // Load configuration
        var config = ChatConfiguration.Load(...);
        
        // Initialize Convex client
        Client = config.CreateClientBuilder().Build();
        
        // Set up Clerk authentication
        var clerkOptions = new ClerkOptions
        {
            PublishableKey = config.ClerkPublishableKey, // Load from config
            TokenTemplate = "convex"
        };
        
        _clerkTokenService = new GodotClerkTokenService(clerkOptions);
        
        // Configure Convex client with Clerk auth
        await Client.AddClerkAuthToConvexClientAsync(_clerkTokenService, clerkOptions);
        
        // Show auth dialog if not authenticated
        if (!_clerkTokenService.IsAuthenticated)
        {
            ShowAuthDialog();
        }
    }
    
    private void ShowAuthDialog()
    {
        // Load and show the auth dialog scene
        var dialogScene = GD.Load<PackedScene>("res://ClerkAuthDialog.tscn");
        _authDialog = dialogScene.Instantiate<ClerkAuthDialog>();
        AddChild(_authDialog);
        
        _authDialog.AuthenticationSucceeded += OnAuthenticationSucceeded;
        _authDialog.Initialize(_clerkTokenService!);
        _authDialog.PopupCentered();
    }
    
    private void OnAuthenticationSucceeded()
    {
        GD.Print("Authentication successful!");
        // Continue with your app logic
    }
}

3. Use in Your Scenes

In your chat scene or other components:

using Convex.Client.Extensions.Clerk.Godot;

public partial class ChatScene : Control
{
    private GodotClerkTokenService? _clerkTokenService;
    
    private void OnSignInPressed()
    {
        // Show auth dialog
        var dialogScene = GD.Load<PackedScene>("res://ClerkAuthDialog.tscn");
        var dialog = dialogScene.Instantiate<ClerkAuthDialog>();
        AddChild(dialog);
        dialog.AuthenticationSucceeded += () => {
            GD.Print("Signed in!");
            // Update UI, load data, etc.
        };
        dialog.Initialize(_clerkTokenService!);
        dialog.PopupCentered();
    }
    
    private void OnSignOutPressed()
    {
        _clerkTokenService?.SignOut();
        // Update UI, clear data, etc.
    }
}

How It Works

  1. Device Code Flow: When authentication is needed, the app requests a device code from Clerk.
  2. User Code Display: The dialog displays a user code (e.g., "ABC-123") and verification URL.
  3. Browser Authentication: User opens the URL in their browser and enters the code.
  4. Polling: The app polls Clerk's API until authentication completes.
  5. Token Retrieval: Once authenticated, the app retrieves a JWT token for Convex.

Manual Token Entry

If device code flow fails or the user prefers manual entry:

  1. Click "Enter Token Manually" in the dialog
  2. Paste your Clerk token from the Clerk dashboard
  3. Click "Sign In"

Configuration Options

ClerkOptions

  • PublishableKey - Your Clerk publishable key (required)
  • TokenTemplate - JWT template name (default: "convex")
  • EnableTokenCaching - Enable token caching (default: true)
  • TokenCacheExpiration - Cache expiration time (default: 5 minutes)

Error Handling

The package handles various error scenarios:

  • Network errors: Shows error message, allows retry
  • Expired device code: Automatically restarts flow
  • User cancellation: Allows manual token entry
  • Invalid token: Clears auth state, allows restart

Notes

  • Clerk's device code flow API endpoints may need verification against Clerk's actual API
  • If Clerk doesn't support standard OAuth2 device code flow, the implementation may need adjustment
  • The ClerkAuthDialog.tscn scene file should be added to your Godot project
  • GodotSharp package is required (automatically included when using Godot.NET.Sdk)

Requirements

  • .NET 8.0 or later
  • Godot 4.x with .NET support
  • Convex.Client.Extensions.Clerk (automatically included)

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated

Initial release (0.0.1) of Godot-specific Clerk authentication package with OAuth 2.0 Authorization Code Flow for desktop apps. See CHANGELOG.md for full details.