0

I was developing my own LOGINAPI in PHP trying to implement JWT using FIREBASE. I did it successfully but know, I am having some troubles managing that token in the clientside.

I have the token stored in cookies (or _SESSION). The thing is that I don't know how get the data from the token in the client side.

For example, the token stores

 [profile] => Array ( [name] => xxx [first_name] => xxx [last_name] => xxx [email] => xxx [id] => 123456 )

How should I decode the token to get the data stored? Should I create another API the get the resource and use a request method?

mega6382
  • 9,211
  • 17
  • 48
  • 69
Julian Mendez
  • 3,162
  • 2
  • 13
  • 36
  • What platform is your clientside? Javascript? If yes then this is a possible duplicate of https://stackoverflow.com/questions/38552003/how-to-decode-jwt-token-in-javascript – Matey Oct 20 '17 at 19:49
  • I don't know what should I use. Maybe I will use another endpoint to decode the JWT. Also i code it why a secret key, dont know how to handle that – Julian Mendez Oct 20 '17 at 21:25
  • You mentioned you had troubles decoding the token on client side. That means you must know what your client side is. Is it a mobile application? Is it a webpage? Is it a standalone desktop application? – Matey Oct 21 '17 at 07:12
  • it's a webpage. I don't know what should I use in the client side, and how – Julian Mendez Oct 21 '17 at 21:09
  • If it's a webpage then Javascript it is. See my first comment for further clues. – Matey Oct 21 '17 at 21:56
  • that is not helping me. I dont know where should i store the JWT and how handle it in the client side. I know how to decode, the thing is to apply the method. Your first reply it's just a way to decode it. Should i use headers? cookies? session? – Julian Mendez Oct 22 '17 at 22:17
  • You said you didn't know how to get the data from the token. Storing the token is another thing. Token can be stored on client side in local storage or in cookies. Session is a way of storing things on server side. Headers is a way of transporting token from client to server. I strongly suggest you make your question clearer. – Matey Oct 23 '17 at 08:10

0 Answers0