Hello everyone,
I’m totally lost with APIs and localStorage… I’ve been stuck on this for 3 days straight and nothing I try seems to work. I just don’t get it. A few times I managed to see the auth_token
appear in “step by step” debugging during login, but I already forgot how I did it because I feel like I’ve tried everything.
Let me explain:
My goal is to display a message like Hi <first_name> on my dashboard page.
My setup in Xano:
-
My login API returns the
auth_token
as an object:{ "auth_token" : "string value" }
-
My auth/me API (authentication required) returns:
{ "id": uuid, "email": email, "First_Name": text, "Last_Name": text }
My setup in Bubble:
-
In the API Connector, I configure my API as a JSON Action.
-
For the GET request, in the header I set:
-
Key =
Authorization
-
Value =
Bearer
-
-
For initialization I used Bearer + a real token and it worked fine.
I also place the LocalStorageA element (1px by 1px) on both my login page and my dashboard page.
Login page workflow:
When the Login button is clicked →
-
Call my API log-in with
Input email's value
andInput password's value
-
Write LocalStorageA
-
keys:
auth_token
-
values:
Result of step 1's auth_token
-
-
Go to Dashboard.
In Bubble’s step-by-step debugger, I do see my
auth_token
in the value after login.
Dashboard page workflow:
When the page loads →
-
Get LocalStorageA (keys:
auth_token
) -
Call my API auth/me with:
- Header
Authorization = Bearer LocalStorageA's Values:first item
(I also tried withoutBearer
, and withoutfirst item
, but still no success)
- Header
-
Create a custom state on the dashboard for
firstname
. -
My text element shows:
dashboard's first_name
.
In step-by-step debugging, I can see my
auth_token
at every step.
But at the final step, the API returns:
{ "code":"ERROR_CODE_UNAUTHORIZED", "message":"Invalid token." }
And in Xano’s request history it also shows Error 401 – Invalid Token.
What I also tried:
I tried the Current User method:
Login button → Call API log-in → Make changes to current user (auth_token = Result of step 1's auth_token
) → Go to dashboard.
In the API Connector, I set Use as Action
with Authorization = Bearer
(just Bearer).
When I initialized with a real token, it showed me id
and First_Name
.
But in step-by-step, at the step Make change to current user, the auth_token
is empty — while in Xano I can see the request was sent and the token returned.
And when I try to display dashboard's current user's first_name
, nothing shows — makes sense since the console says Invalid Token.
In short:
I just don’t get it. Why is this so difficult?
All I want is to store the token after login, call /auth/me
with that token, and show the user’s first name.
If anyone can help me get this working, I’d really appreciate it
Arthur