After a good bit tracing tonight, turns out the problem was THIS GUY.
In the link I referenced earlier, the example files are very close to production-ready, but there's some customization/tweaking that needs to be done. I noticed in authenticate_user.rb, I had to provide an email and password and replace the generic User
class with my own class (in .user()); I updated that and was able to log in and that was that - or so I thought... I wasn't able to get the API to return a valid token in my response header. In a case of tl;dr, it turns out I also needed to make the same
customization and replace User in authorize_api_request.rb as well (in .user()).
On Wednesday, March 1, 2017 at 8:53:36 AM UTC-5, Joe Tseng wrote:
I know this issue isn't entirely Ruby-specific, but I'm sure lots of RoR people use Passenger so maybe someone's seen this...
I'm working on an SPA calling a RESTful API driven by Rails/Passenger/nginx. I did notice that on occasion, despite having already logged into the SPA, if I access a page that called a JWT token-protected endpoint, the API would return a 401 error and
I'd be logged out. The only way I could get the 401 to go away was if I restarted nginx.
After some googling, I found this: https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_pool_idle_time
And I thought the solution was to assign the value to 0 to allow for no timing out. I went ahead and did this and restarted the service to make the value take effect, but the 401 error came back again after a bit of idle time.
I also upped the idle time to 86400 seconds to see if that has any effect, but my API still fails after ~5 minutes. Has anyone seen this, and what did you do to solve the issue?
Thanks,
- Joe
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)