gpt4 book ai didi

Django OAuth 工具包设置问题

转载 作者:行者123 更新时间:2023-12-02 08:38:55 25 4
gpt4 key购买 nike

我正在关注https://django-oauth-toolkit.readthedocs.org/en/0.7.0/rest-framework/getting_started.html用于使用 Rest 框架设置 Django OAuth Toolkit。

如步骤 4 所示:https://django-oauth-toolkit.readthedocs.org/en/0.7.0/rest-framework/getting_started.html#step-4-get-your-token-and-use-your-api

它说要获取 token ,我们需要执行如下操作:

curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" http://<client_id>:<client_secret>@localhost:8000/o/token/

我对此过程的实际curl请求看起来像这样(对于已经生成的client_id和client_secret)

curl -X POST -d "grant_type=password&username=test&password=test" http://mbqvonqO7sI1lrh87uDd.C1U..NbKTb@0=eCM8Fl::2O=!0ZjE5UCha0UW?Oie-XCVUn;3XtmjT2SbFpzDJeM@Bn3.vPS!KLoDqVz7L-3.FfjP9v6yYyu2ghxObnIdIWppu=J@RPxPOfU@Q7KPt7da.?Bg0o5kCt5tY:wamsF@127.0.0.1:8000/o/token/

它没有返回任何响应并给出错误“bash: !0: 未找到事件”

调用有错误吗?

最佳答案

问题在于注册应用程序期间生成的“客户端 ID”和“客户端 key ”( http://django-oauth-toolkit.readthedocs.org/en/0.7.0/rest-framework/getting_started.html#step-3-register-an-application )

“client id”和“client Secret”包含特殊字符,不能以文档中提到的方式与curl请求一起使用。

我们可以按照Almalki建议的方式使用它:

curl -X POST -d "client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=password&username=YOUR_USERNAME&password=YOUR_PASSWORD" http://localhost:8000/o/token/

关于Django OAuth 工具包设置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22118305/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com