jundalisay

jundalisay

Phoenix + Flutter: How to get the User ID from Access Token in Pow?

I’m new to user authentication via Phoenix API on Flutter Android.

I used Pow to make a user API which outputs renewal_token and access_token.

How can I use the access_token to get the user’s id so that I can make a GET request of his products in the API below?

Or is there a way to send the access token back to Phoenix to get the products of the user_id associated with that token?

final response = await dio.get('http://192.168.100.145:4000/api/products?userId=$userId');

ChatGPT is not yet updated on Pow.

Marked As Solved

jundalisay

jundalisay

I got stuck at trying to fetch user info from the Pow access token, so I switched to using Guardian ID token through this tutorial: https://www.youtube.com/watch?v=beW3yscX3ww and this repo https://github.com/ElixirMentor/real_deal_api/tree/main

After login, Flutter just gets the user’s account UUID then passes that around between Flutter widgets.

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement