4

I'm using graphene-django and django-graphql-jwt in my django project. When I set invalid credentials server raises 'Invalid credentials' exception.

Are invalid credentials supposed to raise an exception on the server? When I test tokenAuth mutation with wrong data Django server raises exception.

Django server log:

  File "/Users/cgf/.local/share/virtualenvs/testdjangoauthbackend-183R1gMP/lib/python3.7/site-packages/promise/promise.py", line 487, in _resolve_from_executor
    executor(resolve, reject)
  File "/Users/cgf/.local/share/virtualenvs/testdjangoauthbackend-183R1gMP/lib/python3.7/site-packages/promise/promise.py", line 754, in executor
    return resolve(f(*args, **kwargs))
  File "/Users/cgf/.local/share/virtualenvs/testdjangoauthbackend-183R1gMP/lib/python3.7/site-packages/graphql/execution/middleware.py", line 75, in make_it_promise
    return next(*args, **kwargs)
  File "/Users/cgf/.local/share/virtualenvs/testdjangoauthbackend-183R1gMP/lib/python3.7/site-packages/graphql_jwt/decorators.py", line 106, in wrapper
    result = f(cls, root, info, **kwargs)
  File "/Users/cgf/.local/share/virtualenvs/testdjangoauthbackend-183R1gMP/lib/python3.7/site-packages/graphql_jwt/decorators.py", line 89, in wrapper
    _('Please, enter valid credentials'))
graphql.error.located_error.GraphQLLocatedError: Please, enter valid credentials
cristhiam
  • 496
  • 1
  • 4
  • 17

2 Answers2

2

I also experienced the same thing. Actually they are showing the stack trace intentionally. I think, this issue will be resolved soon. Check out this thread for the details.

Ijharul Islam
  • 1,429
  • 11
  • 13
1

django-graphql-auth extends django-graphql-jwt to add more features, like registration, email verification...

One of the advantages is that it returns a standard output, containing success and errors.

For example, instead of raising an error, like in django-graphql-jwt for invalid credentials, it return:

{
  "data": {
    "tokenAuth": {
      "success": false,
      "errors": {
        "nonFieldErrors": [
          {
            "message": "Please, enter valid credentials.",
            "code": "invalid_credentials"
          }
        ]
      },
      "token": null,
      "refreshToken": null,
      "unarchiving": false,
      "user": null
    }
  }
}
pedrobern
  • 1,134
  • 9
  • 24