Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@nholden
Copy link
Member

@nholden nholden commented Oct 29, 2025

We're introducing API keys to help developers provide secure authentication to their APIs. In workos/workos-node#1373, we added a method to the workos-node SDK to expose the validate API key endpoint. This PR adds a function that Next.js apps can use to parse the Bearer Authentication header and validate the API key.

Here's what a call to this new function might look like in a developer's application:

import { NextResponse } from 'next/server'
import { validateApiKey } from '@workos-inc/authkit-nextjs'

export async function GET() {
  const { apiKey } = await validateApiKey()

  if (!apiKey) {
    return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
  }

  return NextResponse.json({ success: true })
}

@nholden nholden requested a review from nicknisi October 29, 2025 00:57
@nholden nholden self-assigned this Oct 29, 2025
@nholden nholden requested a review from a team as a code owner October 29, 2025 00:57
@linear
Copy link

linear bot commented Oct 29, 2025

@nholden nholden force-pushed the feature/auth-5410-add-validate-api-key-to-authkit-nextjs-sdk branch 3 times, most recently from 1513f7c to 59b1ab5 Compare October 29, 2025 01:06
@nholden nholden force-pushed the feature/auth-5410-add-validate-api-key-to-authkit-nextjs-sdk branch from 59b1ab5 to eb9e750 Compare October 29, 2025 01:10
src/validate-api-key.ts Outdated Show resolved Hide resolved
src/validate-api-key.ts Outdated Show resolved Hide resolved
nholden and others added 2 commits October 29, 2025 13:39
Co-authored-by: Michael Hadley <m@mthadley.com>
Co-authored-by: Michael Hadley <m@mthadley.com>
@nholden nholden merged commit 9a3f759 into main Oct 29, 2025
4 checks passed
@nholden nholden deleted the feature/auth-5410-add-validate-api-key-to-authkit-nextjs-sdk branch October 29, 2025 21:39
@nholden nholden mentioned this pull request Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.