A user, erik_chan, is experiencing an error (“You are not permitted to view the requested resource”) when trying to access a private category using the Ruby API. They have tried authenticating with different users, including the system user, but still encounter the issue.
erik_chan mentions that they expect users with admin rights to be able to access private categories via the API.
Other users, such as chenny408 and j127, report similar issues.
simon suggests that the problem might be due to incorrect API credentials or authentication method. They point out that the Api-Key and Api-Username need to be set in the request headers, and the API field names should use dashes (-) instead of underscores (_).
j127 confirms that setting the Api-Key and Api-Username in the request headers resolves the issue. They also mention that the Discourse API documentation might need to be updated to reflect this.
simon updates the relevant documentation and deletes outdated posts.
Have you attempted to generate a key from your account? You are the admin who created the forum, yes? You say “users/system” so I am wondering if you tried your own account.
I have tried both my username and system with no luck. I can’t call client.category_latest_topics(<category_name>) even though the user has permissions to the category
지금 이 문제를 겪고 있는 사람이 더 있나요? 2일 동안 API를 사용하려고 시도하고 있지만, 매번 비슷한 오류가 발생합니다. 제가 단계를 놓치고 있는지, 아니면 무언가 변경되었는지 확실하지 않습니다.
system 사용자를 위한 새로운 API 키를 생성했습니다. 또한 모든 사용자를 위한 API 키를 생성한 후 관리자 계정을 사용해 보기도 했습니다.
discourse_api Ruby 제보를 사용했습니다:
DiscourseApi::UnauthenticatedError ({"errors"=>["You are not permitted to view the requested resource. The API username or key is invalid."], "error_type"=>"invalid_access"})
원시 Ruby 코드에서 발생하는 오류에 대해 말씀드리자면, 문제는 Api-Key와 Api-Username을 요청 헤더에 설정해야 한다는 점입니다. 또한 API 필드 이름은 밑줄(_)이 아닌 대시(-)를 사용해야 합니다. 요청 인증 방법에 대한 자세한 내용은 https://docs.discourse.org/ 상단의 Authentication 섹션을 참고해 주세요.
Discourse API gem을 사용하여 호출할 때 발생하는 오류의 원인은 정확히 알 수 없습니다. 가장 가능성 높은 원인은 올바른 API 자격 증명을 사용하지 않고 있기 때문일 것입니다. User Level이 All Users로 설정된 API 키를 사용하고 있는지 확인해 주세요: