英文:
Django-RQ API_TOKEN configuration to access to stats endpoint
问题
我正在尝试从django-rq队列中检索一些统计信息,但我在尝试访问Django-Rq文档中提供的URL时遇到了一些困难。
这些统计信息也可以以JSON格式通过/django-rq/stats.json获得,只有工作人员可以访问。如果您需要通过其他HTTP客户端(用于监视)访问此视图,您可以定义RQ_API_TOKEN并通过/django-rq/stats.json/<API_TOKEN>进行访问。
嗯,我已经在我的settings.py中定义了一个简单的RQ_API_TOKEN,仅用于测试目的。
RQ_API_TOKEN = "AAABBBCCC"
我尝试通过Postman访问它,但我不断收到以下响应:
{"error": true, "description": "在访问此视图之前,请在settings.py中配置API_TOKEN。"}
我尝试将令牌作为标头或甚至查询参数发送,但仍然无法按预期工作。
我尝试过的示例URLS(带有查询参数):
- django-rq/stats.json/?token=AAABBBCCC
- django-rq/stats.json/?api_token=AAABBBCCC
- django-rq/stats.json/?API-TOKEN=AAABBBCCC
- django-rq/stats.json/?API_TOKEN=AAABBBCCC
我也尝试了相同的操作,但没有查询参数,并将令牌插入为具有相同键的标头。什么都不起作用。
英文:
I'm trying to retrieve some statistics from the django-rq queues and I'm having some difficulties to access to the provided URL from the Django-Rq documentation
> These statistics are also available in JSON format via /django-rq/stats.json, which is accessible to staff members. If you need to access this view via other HTTP clients (for monitoring purposes), you can define RQ_API_TOKEN and access it via /django-rq/stats.json/<API_TOKEN>.
Well, I have defined a simple RQ_API_TOKEN
just for testing purposes in my settings.py
RQ_API_TOKEN = "AAABBBCCC"
And I'm trying to access it via Postman but I keep receiving the following response:
> {"error": true, "description": "Please configure API_TOKEN in settings.py before accessing this view."}
I've tried to send the token in the headers o even a query param, but it still doesn't work as is intended to work.
Example URLS that I've tried with query params:
- django-rq/stats.json/?token=AAABBBCCC
- django-rq/stats.json/?api_token=AAABBBCCC
- django-rq/stats.json/?API-TOKEN=AAABBBCCC
- django-rq/stats.json/?API_TOKEN=AAABBBCCC
The same I've tried, but leaving no query param and inserting the token as a header with the same keys. Nothing works.
答案1
得分: 0
"django-rq/stats.json/AAABBBCCC/"
有时候,最简单的事情就是正确的做法。
英文:
Well, it turns out that the correct URL to hit was:
django-rq/stats.json/AAABBBCCC/
Without any query param or header. Sometimes the simplest thing is the right thing to do.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论