Django GraphQL JWT:tokenAuth 突变返回“str 对象没有属性解码"; [英] Django GraphQL JWT: tokenAuth mutation returns "str object has no attribute decode"
问题描述
目前我正在从文档页面运行 django-graphqljwt 的基本示例.https://django-graphql-jwt.domake.io/en/latest/quickstart.html
Currently I'm running a basic example of django-graphqljwt from the documentation page. 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
界面中抛出以下错误.注意,如果我输入不正确的凭据,它会抛出请输入有效凭据
";而不是下面的.
However if I run the tokenAuth
mutation it throws me the below error in the GraphiQL
interface. Note that if I enter incorrect credentials it throws an "Please enter valid credentials
" instead of the below.
{
"errors": [
{
"message": "'str' object has no attribute 'decode'",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"tokenAuth"
]
}
],
"data": {
"tokenAuth": null
}
}
推荐答案
我发现这是 github 上 django-graphql-jwt
包的一个未解决的问题,并且能够通过求助于解决它PyJWT
的 1.7.0
版本.当前安装的是版本 2.0
I found this as an open issue on github for the django-graphql-jwt
package and was able to resolve it by resorting to the 1.7.0
version of PyJWT
. Currently installed was version 2.0
https://github.com/flavors/django-graphql-jwt/问题/241
这篇关于Django GraphQL JWT:tokenAuth 突变返回“str 对象没有属性解码";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!