Get the authenticated user in a Serverless Function #278
elitan
started this conversation in
Tips and Tricks
Replies: 1 comment 3 replies
-
If we want to call the function by adding a Hasura action so that everything flows through the graph, is there a way to receive the same user authorization header automatically? From what I've tried, using a Hasura action to call a function acts as an unauthenticated call. The database event trigger documentation specifies that the It would be great to just have the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When the user is signed-in and you make a function call the access token is automatically attached as a header.
You can use this header to get user information (like the user's id).
Here is a helper function
getUser()
that verifies the access token and returns information about the user.And use
getUser()
like this:You can trust this information to be correct since we've verified the access token with the
NHOST_JWT_SECRET
.Beta Was this translation helpful? Give feedback.
All reactions