This Endpoint Requires Bearer token

  • flibbertigibbet4life-1330940094038937680

    mightBeMatt

    19 days ago

    I have a simple login page that currently works which redirects the user to another page. On that page I am trying to retrieve information about that user. My backend is Supabase.

    I set up an API call for the user to Supabase and I made the formula in the screenshot to pass the bearer token to the API. But in preview it keeps giving me error 401: This Endpoint Requires Bearer token. What am I doing wrong?
    1330940095854940260-image.png
  • Tod-1330940098241499257

    Tod

    19 days ago

    Great energy @mightBeMatt! Your continuous contribution to the toddle Community just made you advance to Community Level 1!
  • max.kayr-1330942210379874367

    Max

    19 days ago

    That part looks good. Can you share the setup of your api call and also the login flow on your login page?
  • flibbertigibbet4life-1330975090623643669

    mightBeMatt

    19 days ago

    1330975089747038290-image.png
    1330975090069733417-image.png
    1330975090292166716-image.png
  • max.kayr-1330977627229655110

    Max

    19 days ago

    You should set the session cookies "on success" of the sign in call. Right now, the session cookies are set before you get the answer
  • Also, when do you do the redirect?
  • flibbertigibbet4life-1330979098918654013

    mightBeMatt

    19 days ago

    the redirect is on the call: sign in success
  • flibbertigibbet4life-1330980109837926474

    mightBeMatt

    19 days ago

    I guess after typing this out it I see that it is redirecting before it has a chance to set the cookie
  • lucasg-1330980569433112606

    Lucas G

    19 days ago

    It is a common one.
    It should be Sign in -> on success Set Cookies -> on success Redirect
    💪1
  • flibbertigibbet4life-1330984495280816240

    mightBeMatt

    19 days ago

    Hmmm so i changed it now but I still get the same error. Moved the set session cookies to inside the api onSuccess
    1330984495226032274-image.png
  • flibbertigibbet4life-1330985346149781566

    mightBeMatt

    19 days ago

    maybe it is how I am setting the access token? I've tried a few different ways
    1330985345814102056-image.png
  • max.kayr-1330986372789440612

    Max

    19 days ago

    You have nothing bound to the access token. It will always be empty
  • flibbertigibbet4life-1330986604894097410

    mightBeMatt

    19 days ago

    sorry for the confusion. In that screenshot i had temporarily deleted it.
  • flibbertigibbet4life-1330987097456250916

    mightBeMatt

    19 days ago

    the formula above is what I am currently using. Getting 401 error
  • max.kayr-1330989318986268795

    Max

    19 days ago

    1. When do you redirect after calling the sign up endpoint?
    2. You can add a log node on success to see what the return data structure looks like
  • flibbertigibbet4life-1330993034304819403

    mightBeMatt

    19 days ago

    1330993034124329020-image.png
  • Tod-1330993036435394734

    Tod

    19 days ago

    Great energy @mightBeMatt! Your continuous contribution to the toddle Community just made you advance to Community Level 2!
  • max.kayr-1330993781662552075

    Max

    19 days ago

    The "go to URL" needs to go in the "Success" Branch of the "Set Session cookie" action.
  • Right now, you navigate away before you received the answer from the api and set the cookie
  • flibbertigibbet4life-1330994489149489264

    mightBeMatt

    19 days ago

    good point. Yeah i guess there isn't a good reason to have it outside. But it still redirects inside the success branch and gives me an error
  • max.kayr-1330997144597041152

    Max

    19 days ago

    Can you share your project URL? Then I can take a look
  • flibbertigibbet4life-1331000178114826280

    mightBeMatt

    19 days ago

    well now it seems to be working! I'm not sure if I could tell you why since it doesn't seem like I really changed any of the logic
  • lucasg-1331000189414281340

    Lucas G

    19 days ago

    Is it on success of the set session?
  • As noted earlier, it should be Sign in -> on success Set Cookies -> on success Redirect
  • lucasg-1331000508512469192

    Lucas G

    19 days ago

    Otherwise, it won't work consistently
  • flibbertigibbet4life-1331000584475508797

    mightBeMatt

    19 days ago

    Yes that is how i have it set
  • flibbertigibbet4life-1331001687825186946

    mightBeMatt

    19 days ago

    Ah I see what you are saying. If it doesn't set cookies successfully then it shouldn't redirect. Thank you all for your patience and assistance!
    💪1
  • lucasg-1331002232056975512

    Lucas G

    19 days ago

    Yeah, perhaps my comment wasn't clear enough.
    I meant it should be Sign in and on success of the sign in API call, Set Session Cookies and on success setting the access_token, then Go to URL/Redirect
    👍1

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.