Django OAuth工具包安装问题

Django OAuth工具包安装问题,django,oauth,oauth-2.0,django-rest-framework,Django,Oauth,Oauth 2.0,Django Rest Framework,我下面介绍如何使用rest框架设置Django OAuth工具包 与步骤4一样: 上面说要得到token,我们需要做一个卷曲,比如: curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" http://<client_id>:<client_secret>@localhost:8000/o/token/ 未返回任何响应,并出现错

我下面介绍如何使用rest框架设置Django OAuth工具包

与步骤4一样:

上面说要得到token,我们需要做一个卷曲,比如:

curl -X POST -d "grant_type=password&username=<user_name>&password=<password>" http://<client_id>:<client_secret>@localhost:8000/o/token/
未返回任何响应,并出现错误“bash:!0:未找到事件”


调用中是否有错误?

您可以将客户端id和客户端机密设置为POST参数:

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/
问题在于注册应用程序()期间生成的“客户id”和“客户机密”)

“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/

我和OP有同样的问题,这是唯一对我有效的解决方案:

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

我找到了这个解决方案。这里有一个很好的解释。

请尝试用双引号或单引号将您的url括起来,因为它包含许多不符合shell参数条件的字母,但没有引号。我注意到您的客户id和客户机密中也有at符号和列。我认为curl解析器无法区分client和client_secret。
curl -X POST -d 'grant_type=password&username=<username>&password=<password>' --user '<client_id>:<client_secret>' 'http://localhost:8000/o/token/'