【发布时间】:2023-02-06 03:16:14
【问题描述】:
我按照本教程 https://github.com/wagnerdelima/drf-social-oauth2/tree/32fe4e4f871777eec4a835ddd37ce2fb50712267 获取我的其余 API
在
测试设置
curl -X POST -d "client_id=<client_id>&client_secret=<client_secret> &grant_type=password &username=<user_name>&password=<password>" http://localhost:8000/auth/token我确实尝试请求我自己的令牌
curl -X POST -d "client_id=<nBezU5O1OJT74Vt7bItsbdTgoUqcY4ytJuUcpibO> &client_secret=<pbkdf2_sha256$390000$mSUCDwLkV3iY4fYjAgEEMq$91mdrFYgz3mj5mayJxT6wcjPFLpMS1Hc3Z4TNl7PySc=> &grant_type=password &username=<admin@gmail.com>&password=<admin>" http://localhost:8000/auth/token但它在说
{"error":"invalid_client"}我修改用户模型以消除用户名并改用电子邮件地址
class CustomUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField(_('email address'), unique=True) is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=True) date_joined = models.DateTimeField(default=timezone.now) USERNAME_FIELD = 'email' REQUIRED_FIELDS = [] objects = CustomUserManager() def __str__(self): return self.email请帮忙
编辑: 在我的 Django 终端中它说
未经授权:/auth/token
【问题讨论】:
标签: django-rest-framework oauth-2.0