简体   繁体   English

请求用户令牌时出现奇怪的错误

[英]Strange error while requesting user token

I am able to login to the API and get back a bearer token, however if I then try to request an api token for the admin user, I get:我能够登录 API 并取回不记名令牌,但是如果我随后尝试为管理员用户请求 api 令牌,我会得到:

{
    "message": "Not Found",
    "internalMessage": "The rest endpoint or resource for given path {/api/v2/users/715ece57728243a993dce051949d2e90/token} could not be found. Please verify that your Accept header is set correctly. I got {application/json}. It must accept {application/json}"
}

The uuid was copy/pasted from /mesh-ui/#/admin/users/715ece57728243a993dce051949d2e90 uuid 是从/mesh-ui/#/admin/users/715ece57728243a993dce051949d2e90复制/粘贴的

I have both Accept and Content-Type headers set to application/json in the request.我在请求中将AcceptContent-Type标头设置为application/json The API request is going to localhost with stock install ( mesh-compose ) using the gentics/mesh:1.7.1 image. API 请求将使用gentics/mesh:1.7.1映像通过 stock install ( mesh-compose ) 发送到本地主机。 All I've done in the UI is login as the admin to set the first password.我在 UI 中所做的就是以管理员身份登录以设置第一个密码。

Any ideas what I'm doing wrong here?任何想法我在这里做错了什么?

Cheers, and thank you for your time!干杯,谢谢你的时间!

edit编辑

I noticed MeshRestClient is sending requests to /api/v1 .我注意到MeshRestClient正在向/api/v1发送请求。 Is this expected?这是预期的吗? Am I using the wrong endpoint perhaps?我是否使用了错误的端点? For clarity, my ultimate goal is to request an API token I can give to MeshRestClient so it can login without user/pass combo.为清楚起见,我的最终目标是请求一个我可以提供给MeshRestClient的 API 令牌,以便它可以在没有用户/密码组合的情况下登录。

Currently the only api changes for v2 are within the GraphQL endpoint.目前,v2 的唯一 api 更改在 GraphQL 端点内。 So loading the token should work for API v1 / v2.因此加载令牌应该适用于 API v1 / v2。

Loading a new token must be done via a POST request.必须通过POST请求加载新令牌。

See https://getmesh.io/docs/api/#users__userUuid__token_posthttps://getmesh.io/docs/api/#users__userUuid__token_post

I suspect you are using the wrong HTTP method.我怀疑您使用了错误的 HTTP 方法。

POST is used since this operation is modifying the user and to avoid accidentally generating a new toke when pasting the URL in the browser.使用 POST 是因为此操作会修改用户并避免在浏览器中粘贴 URL 时意外生成新令牌。

The previously issued token will be invalidated.之前发行的令牌将失效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM