Closed cassiompf closed 3 years ago
I've already managed to resolve it. The problem with the jwt configuration. I was doing something like this:
config.jwt do |jwt|
jwt.secret = Rails.application.credentials[:devise_jwt_secret_key]
end
where actually, it was supposed to be like this:
config.jwt do |jwt|
jwt.secret = Rails.application.credentials[Rails.env.to_sym][:devise_jwt_secret_key]
end
When I try to authenticate the user in my api, and use Bearer token in another controller that needs authentication, it always returns a message that I'm not authenticated: "No verification key available". I use the following code to create a user session:
And on my route that needs authentication I use:
before_action :authenticate_user!, only: %i[create destroy]
My routes.rb file:
Print of response trying to access an authenticated route:
After leaving
store: true
the authentication token worked. Can anyone explain to me why this is? I thought it worked without the cookie.I I'm using the latest Rails (6.1.4.1), Ruby (3.0.1) and gem devise-jwt (0.8.1) versions