2
我已经创建了Django的REST框架项目和安装的Django身份验证提供者,创造了一个应用程序,生成的客户端ID和客户端密钥,当我测试的应用程序在Django项目中创建的应用程序使用卷曲请求得到的Oauth 2无效客户端错误,同时检查
卷曲-X POST -d “grant_type =密码&用户名= &密码=” -u “:” http://localhost:8000/o/token/
我测试通过给我的用户名,密码,CLIENT_ID和client_request表示像
错误{ “错误”: “invalid_client”}
settings.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',
)
}
url.py:url(r'^ o /',include('oauth2_provider.urls',namespace ='oauth2_provider')), – Ravi
您的网址不包含考虑令牌的正则表达式部分,或者它必须是'r “^ O/$' – dmitryro
它必须是'^ O /(P [\ W - ] +)$'或,如果有更多的参数后令牌'2 O /(P [\ W - ] +)/$' –
dmitryro