bobfp
Recreating Magic Link flow with Ash Typescript
Hi everyone,
I’m migrating a Magic Link authentication flow from Phoenix LiveView to a SolidJS SPA using Ash TypeScript, and I’m stuck on retrieving the authentication token.
Background
-
Using AshAuthentication’s built-in magic link resources (which worked perfectly out-of-the-box with LiveView)
-
Now building a JS SPA (SolidJS) that needs to interact with the same backend via the RPC client
-
The LiveView implementation handled the token automatically, but I want to manage it manually in the SPA
What I’m trying to do
Recreate the same Magic Link flow in my SPA:
-
User requests a magic link via email
-
User clicks the link and is authenticated
-
The app receives and stores the authentication token for subsequent API calls
Current status
Successfully requesting the magic link using AshAuthentication’s request_magic_link action
Successfully calling the sign-in-with-magic-link action
Cannot retrieve the authentication token after sign-in to store it client-side
The problem
From what I can tell, the token appears to be returned via metadata in the response, but the RPC client doesn’t seem to expose this metadata (or I’m not accessing it correctly).
Question
-
How do I access response metadata (specifically the auth token) from AshAuthentication’s magic link sign-in action through the RPC client?
-
Is there a different pattern I should be following when using AshAuthentication with a JS SPA instead of LiveView?
Any guidance on properly handling AshAuthentication tokens in a decoupled frontend would be greatly appreciated!
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 2 of 2 Posts
zachdaniel
Ah…right. I think the RPC client may need to be updated to support displaying metadata in its results. You’ll need to open an issue for this
bobfp
No worries, will do.
For anyone else that has a similar issue, I found a workaround by getting the token in a calculation: