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
system ユーザー用に新しい API キーを作成しました。また、すべてのユーザー用に API キーを作成し、その後で管理者アカウントを使用することも試みました。
discourse_api Ruby gem を使用した場合:
DiscourseApi::UnauthenticatedError ({"errors"=>["You are not permitted to view the requested resource. The API username or key is invalid."], "error_type"=>"invalid_access"})