自定义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
相关产品推荐
相关产品推荐

