Is it possible to check if KeyFromSecret has an instance and "Abort" if it does not?


I want to use KeyFromSecret to verify the user via token, and I need to abort the process with a custom message to show the user proper information.

I have tried this code, but it doesn’t work:

If(IsNull(Select("instance", KeyFromSecret(request.secret))), Abort("user_not_found"), true)

That code returns this error:

[{"position":["let","checkUser","if","is_null","from"],"code":"instance not found","description":"No key found for secret 13bfc31c.....","failures":null}]

Do you have any ideas how I can catch the KeyFromSecret error and change it?

KeyFromSecret will immediately fail if the secret is invalid, so there is no way to “catch” the error in the current FQL API.

What you may try instead is to create a new client with the secret in order to use CurrentIdentity(). CurrentIdentity() returns a Ref to the instance of a Token.

If the secret does not exist, then the client request will immediately fail with either an invalid secret or unauthorized, which might be more helpful than “no key found for secret”.

Hi @hasimyerlikaya, have you been able to work out your query?


Sorry about the late reply.
I’m using KeyFromSecret and getting a general error message.
I wish we could handle that with FQL X queries :slight_smile:

Thank you for your time.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.