Auth and Graphql query in the app

  • Goal:
  1. User clicks the button
  2. User is prompted to login
  3. Only authenticated users are allowed to see or perform queries.
    or
  4. A modal that users are asked to login with their credentials
  5. Only authenticated users are allowed to see or perform queries.
  • Steps:
    We set up a Graphql endpoint under Resources where people can make queries/mutations that have a custom authentication flow.

In the app, I have a button that makes a query to that endpoint. However, it does not prompt users to add their login credentials. We get users not found by clicking that button that makes a query.

2 Likes

I'm still stuck on this. Any ideas from the community on a solution or workaround here?

Hey @S_G! Welcome to the community. :wave:

Are you able to share any additional information about your custom authentication flow? Did you set it up to use a modal? Does it ultimately return an access token? Any context would be helpful!

Once we can verify that the configuration of that flow looks good, there should be a few different ways to initiate a custom authentication flow, including the "Auth Login" component.

image

I'm less sure about how to detect whether a user has previously authenticated, though. :thinking: Retool definitely keeps track of that info but I don't know if it is exposed.

HI @Darren, thank you for your reply. this is currently what I have.

I have a graphQL endpoint that makes a custom auth request to Firebase auth.
Once the user is authenticated, we will send that to our graphQL endpoint with Authorization header to perform the query.

the issues:

  1. Inside of the app, I have a login button that I was hoping to use like you mentioned but there is no way for me to select what I set up in the custom auth with the graphQL endpoint
    Screenshot 2024-10-10 at 12.22.28 PM

  2. I have a button that calls the query I set up but it always returns "unauthorized" without asking the user to login with a form.

how can I have a button that both shows the users login form to authenticate and make a query only when user is authenticated?