检查在Django proj中创建的应用程序时,获取Oauth 2无效客户端错误

2024-04-26 12:37:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我在django rest框架中创建了一个项目,安装了django auth provider,创建了一个应用程序,生成了客户机id和客户机机密,当我使用curl请求测试应用程序时

curl-xpost-d“grant_type=password&username=&;password=”-u“http://localhost:8000/o/token/

我通过给出我的用户名、密码、客户端用户名和客户端请求进行了测试,结果显示错误如下

{"error": "invalid_client"}

在设置.py在

 OAUTH2_PROVIDER = {
    # this is the list of available scopes
    'SCOPES': {'read': 'Read scope', 
               'write': 'Write scope', 
               'groups': 'Access to your groups'}
}

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.IsAuthenticated',
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
        'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
        'oauth2_provider.ext.rest_framework.OAuth2Authentication',
    )
}

Tags: djangorest应用程序default客户端客户机authenticationframework