Reputation: 179
I have added the jwt gem to gem file. I can successfully perform a login request, and receive an Authorisation token. I then use the authorisation token to return the User Object. This works fine in development.
However, in production, I am unable to get the User Object using the authorisation token. I receive the message: No verification key available.
My searches led me to this but this is for devise-jwt I also came across this but it wasn't so helpful.
The information from heroku logs --tail --app stag
isn't really helpful
2020-11-25T20:15:30.493583+00:00 app[web.1]: I, [2020-11-25T20:15:30.493522 #4] INFO -- : [398a1a9c-fae2-454a-b991-5a922a679103] [active_model_serializers] Rendered ActiveModel::Serializer::Null with Hash (0.07ms)
2020-11-25T20:15:30.493805+00:00 app[web.1]: I, [2020-11-25T20:15:30.493736 #4] INFO -- : [398a1a9c-fae2-454a-b991-5h922a679973] Completed 422 Unprocessable Entity in 1ms (Views: 0.5ms | Allocations: 1356)
Any help on this will be appreciated, thanks.
Upvotes: 1
Views: 1436
Reputation: 181
Finally, I found the solution for my case. I don't know if it's going to work for you, here is what I did:
First I was using Rails.application.secrets.secret_key_base
as a secret key for my JWT and after reading a bit from other posts with the same issue but using devise-jwt
I said maybe this attribute in Rails secrets is returning nil in Heroku, so I decided to create my own secret key, and that what I did exactly, I just used an environment variable called secret_key then reference it, where I should use it in JWT.
hope this was helpful.
Upvotes: 2