oauth2.0 django rest_framework drf-社会化认证2错误:无效客户端

thigvfpy  于 2023-02-15  发布在  Go
关注(0)|答案(1)|浏览(125)

我按照这个教程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终端里,它说
未经授权:/身份验证/令牌

flseospp

flseospp1#

您需要从client_id的值中删除<>,然后重试。client_id=<client_id>意味着clinet_id=CLIENT_ID不是client_id=<CLIENT_ID>。我希望这样可以解决问题。

相关问题