Community .NET port of @vercel/oidc (version 3.2.0). It resolves the Vercel OIDC token of a project. Not an official Vercel product.
dotnet add package Vercel.Oidc
VercelOidcToken.GetVercelOidcTokenAsync (upstream's getVercelOidcToken) returns the Vercel OIDC token. It reads the x-vercel-oidc-token header of the request context, then the VERCEL_OIDC_TOKEN environment variable. When the token is missing or expired, it refreshes it with the file-backed credentials of the Vercel CLI (vercel login) for the project linked in .vercel/project.json, caches it, and publishes it in VERCEL_OIDC_TOKEN. A login kept only in the system keyring is not read.
using Vercel.Oidc;
var token = await VercelOidcToken.GetVercelOidcTokenAsync(null, cancellationToken);A host that serves Vercel requests supplies the request context (upstream's getContext) with VercelRequestContext.Use, for example from ASP.NET Core middleware. Its x-vercel-oidc-token header is the OIDC token.
using (VercelRequestContext.Use(new Dictionary<string, string?> { ["x-vercel-oidc-token"] = token }))
{
// work that reads the token
}- Keyring-only Vercel CLI logins (newer
@vercel/oidcversions delegate to the CLI for them). index-browser.test.ts: there is no browser export.
- The token is published in
VERCEL_OIDC_TOKENprocess-wide, as in@vercel/oidc3.2.0. - A refresh lock serializes concurrent refreshes in one process (.NET-only).
- Keyring-only Vercel CLI logins are not supported.
Apache-2.0. Derived from @vercel/oidc by Vercel, Inc.