Yes, but that doesn't deal with authentication. My problem was getting the JWT stuff working. The solution ended up being: https://gist.github.com/arohner/8d94ee5704b1c0c1b206186525d9...
From a glimpse, what's said there matches what your code is doing, so thanks a lot for sharing it!