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/Issues/241
这篇关于Django GraphQL JWT:tokenAuth突变返回"str对象没有属性解码".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!