# 关于discourse invalid\_access的提问

**URL:** https://meta.discourse.org/t/asking-about-discourse-invalid-access/310237
**Category:** Development
**Created:** [2024年六月2日 10:12 UTC](https://meta.discourse.org/t/asking-about-discourse-invalid-access/310237 "2024-06-02T10:12:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wings](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wings/32/331381_2.png) [@wings](https://meta.discourse.org/u/wings)
#### Post date: [2024年六月2日 10:12 UTC](https://meta.discourse.org/t/asking-about-discourse-invalid-access/310237/1 "2024-06-02T10:12:20Z")

</div>

您好，

我想咨询一下关于 Discourse 中因 Cookie 导致无效访问的问题。在我的案例中，我尝试在登录后使用从 `/session.json` 获取的 Cookie 来访问 Discourse API。

然而，我遇到了一个问题，即一两天后，Discourse 在使用从登录生成的相同 Cookie 时会返回“无效访问”（`Invalid Access`）错误（注意：在我的案例中，当 Discourse API 返回带有 `Set-Cookie` 值的 `_t=` 标头时，Cookie 会更新）。当我检查 Cookie 时，其过期时间仍在一个月以上（例如 `expires=Tue, 30 Jul 2024 04:04:28 GMT`）。此外，我可以看到用于登录的令牌仍然存在于 `user_auth_tokens` 数据库表中。

我想了解 Discourse 可能使此令牌无效的可能原因。Discourse 数据库中是否有任何特定步骤或标志表明令牌已被声明为无效？

附加信息（我使用的是最新的 Discourse 版本 3.3.0.beta3-dev）

谢谢。

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [2024年六月2日 10:37 UTC](https://meta.discourse.org/t/asking-about-discourse-invalid-access/310237/2 "2024-06-02T10:37:12Z")

</div>

您为什么不遵循本指南？

> [@Create and configure an API key](https://meta.discourse.org/t/create-and-configure-an-api-key/230124):
>
> API keys are generated from the Admin / API page. Go to Admin-Advanced-API Keys: After clicking the “New API Key” button, you will be taken to a page to configure the key: Every API key needs a description, a user level, and a scope. Description The description can be anything that you choose. User Level The User Level drop down allows you to select either “All Users” or “Single User.” If “All Users” is selected, the key can be used on behalf of any user. T…

---

<div class="post-metadata">

### Author: ![wings](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wings/32/331381_2.png) [@wings](https://meta.discourse.org/u/wings)
#### Post date: [2024年六月2日 13:14 UTC](https://meta.discourse.org/t/asking-about-discourse-invalid-access/310237/3 "2024-06-02T13:14:31Z")

</div>

您好 @thoka，感谢您的回复。我正在检查身份验证从网站到应用程序的流程。

关于 API 密钥，这是我尝试使用 Discourse API 开发时可以采用的一个选项。

目前，我想询问有关 Discourse 访问无效的问题。数据库中是否有其他信息（例如标志）可以检查，以表明令牌已失效？
