DEV Community

Discussion on: User Authentication + JWT Authorization With Flutter and Node

Collapse
 
damianoux profile image
Damianoux

Hi Carmine, Good tutorial.
I followed it, but I got problem in HomePage class, in the FutureBuilder.
I was not able to get it working in the original form, I had to modify the headers as follows (my data GET route is /api/auth/profile):

          future: http.read('$SERVER_IP/api/auth/profile', headers: {
            "Authorization": json.decode(jwt)["token_type"] +
                " " +
                json.decode(jwt)["access_token"]
          }),
Enter fullscreen mode Exit fullscreen mode

Using "Authorization": jwt, passed in the whole json and the server did not authenticate, so I was redirect to login ang got error 405 (because /api/auth/login requires POST).

On the server I have nginx+ Laravel 8 and followed the recomended instruction to install jwt-auth.

DId I miss somenthing in the cofiguration of the server?

Thx
Damiano