且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在django rest_framework test中的APIClient标头中添加身份验证令牌

更新时间:2023-12-02 09:46:58

由于在curl中使用Authorization: Bearer,因此还应该使用带Bearer字词的client.credentials而不是Token:

Since you are using Authorization: Bearer in curl, you should also use client.credentials with Bearer word instead of Token:

client.credentials(HTTP_AUTHORIZATION='Bearer ' + self.access_token)