You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自定义nHost认证Rest API接口:端点URL与JWT获取问题咨询

正确对接nHost用户名密码认证获取JWT Token的方法

你当前使用的/auth/login端点不符合nHost Auth API的规范,这是导致"resource does not exist"错误的原因。以下是正确的交互流程:

核心参数说明

  • 正确端点:https://kbvlufgpikkxbfkzkbeg.nhost.run/v1/auth/signin/email-password
  • 请求方法:POST
  • 必填请求头:Content-Type: application/json

请求体格式

必须以JSON格式传递邮箱(用户名)和密码,示例:

{
  "email": "your-user-email@example.com",
  "password": "your-user-password"
}

示例请求(curl)

curl -X POST https://kbvlufgpikkxbfkzkbeg.nhost.run/v1/auth/signin/email-password \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@test.com",
    "password": "secure-password-123"
  }'

成功响应示例

返回结果中包含所需的JWT Token(access_token字段)及其他会话信息:

{
  "session": {
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refresh_token": "ref_abc123xyz",
    "expires_in": 3600,
    "token_type": "bearer"
  },
  "user": {
    "id": "usr_123456",
    "email": "user@test.com",
    "created_at": "2024-01-01T00:00:00Z"
  }
}

额外注意事项

  • 确认nHost控制台的Auth设置中已启用邮箱/密码登录方式
  • 刷新Token使用端点/v1/auth/token/refresh,POST请求携带refresh_token参数
  • 所有nHost Auth相关接口均挂载在/v1/auth路径下,而非直接/auth

内容的提问来源于stack exchange,提问作者wizard_draziw

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 20:51:20