Django GraphQL JWT: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
  }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)