"Error: refresh jwt should not be empty" when using "dgraph-js"

I can take a stab at it. I have a JavaScript environment and can do a quick run through with the dgraph-js-http client this evening.

I should be able to answer the questions above after some hands, I will see if I can reproduce the 401 error code.

When you are using the grpc client you need to use the clientStubFromSlashGraphQLEndpoint method as described on the following topic, just copy and paste the GraphQL endpoint from your Slash Overview page.

Connect using your GraphQL endpoint URL without the /graphql on the end.

As far as which token to use… For the clients use the client token. The admin token I believe is used for scripts that can add and delete Slash backends, not for dealing with the backend itself.

Now back to the OP:

I was not able to replicate this. I have a few more questions that might help diagnose:

  1. How long was it between when it was working and when it suddenly started throwing an error?
  2. Is this a script that is long running any possibly had been over 6 hours since the last setSlashApiKey? I am thinking that maybe this set slash API key is similar to the login requirements and should be run every < 6 hours.
  3. In your application, is this portion of your script running server side or client side?
  4. Have you tried yet to enable the debugging mode with either the dgraph-js or dgraph-js-http clients?

UPDATE: I was able to somewhat reproduce the 401 error with the dgraph-js-http client if I commented out my line where I setSlashApiKey. Are you sure you are using a current API key that you generated from Slash > Settings > Security tab?

If you are just using this Slash API Key, it might be likely that these keys get rotated and are not permanent keys.