Unexpected 401 Unauthorized

Hello Fauns,

We have an interesting error from Fauna servers. We make a simple query with Javscript SDK to verify identity of some user in user collection. The response would be: true(200), false(401) or Error(403). But, sometimes, Fauna server returns a 401 Unauthorized error (not from our managed error system). It’s weird. Sometimes yes, sometimes no. We don’t change api keys on dashboard. Same configuration with all petitions. I don’t undertand the error. If we go to the dashboard shell page, we can get correctly the expected response. The 401 Error is reserved for other purposes and fails our managed error functions with this error.

¿Can you help me?

Thanks,

@cenguidanos Welcome to the Fauna Forums and thanks for reposting this issue here.

401 Unauthorized is usually an indication that the key/token you are using to connect Fauna database is not valid or does not have permission to read the resource.

WebShell in Fauna dashboard creates an admin key internally and would have access to all schema objects by default.

How did you create the key that you use in JS SDK (CreateKey, Login() or created through dashboard and assigned a role ?
Do you have any TTL set on them ?

Hi @Jay-Fauna,

I create this key on dashboard with default server role. I don’t have any TTL setted.

Thanks,

It’s solved. The problem was with managing env vars in multiple machines :unamused:. Thanks!!