Server: verifyCredentials

Verifies pre-extracted credentials against one or more allowed auth modes.

Tries each mode in order — first match wins. A mode is only tried when its credential is present; a JWT that is present but fails verification short-circuits the chain with InvalidCredentialsError instead of falling through to the next mode. Use verifyAuth to extract and verify in a single call.

Parameters

Examples

Multiple auth modes

const credentials = extractCredentials(request)
const { data: auth, error } = await verifyCredentials(credentials, {
  auth: ['user', 'publishable'],
})
if (error) {
  return Response.json({ message: error.message }, { status: error.status })
}