DjangoGraphQLJWT:tokenAuth突变返回“str对象没有属性解码”
目前我正在从文档页面运行 django-graphqljwt 的基本示例。https://django-graphql-jwt.domake.io/en/latest/quickstart.html
import graphene
import graphql_jwt
class Mutation(graphene.ObjectType):
token_auth = graphql_jwt.ObtainJSONWebToken.Field()
verify_token = graphql_jwt.Verify.Field()
refresh_token = graphql_jwt.Refresh.Field()
schema = graphene.Schema(mutation=Mutation)
但是,如果我运行tokenAuth突变,它会在GraphiQL界面中抛出以下错误。请注意,如果我输入不正确的凭据,它会抛出一个“ Please enter valid credentials”而不是下面的。
{
"errors": [
{
"message": "'str' object has no attribute 'decode'",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"tokenAuth"
]
}
],
"data": {
"tokenAuth": null
}
}
回答
我在 github 上发现这是一个未解决的问题,django-graphql-jwt并且能够通过1.7.0使用PyJWT. 当前安装的是版本2.0
https://github.com/flavors/django-graphql-jwt/issues/241
THE END
二维码