Dispatch request not sending me token when i login from api
adnanmirza1 opened this issue · 18 comments
When i login with simple login, I'm receiving the token but i have made another login for API
when i login through it, i'm able to login but i'm not receiving jwt token with it.
In my dispatch request in devise config, i have added the path as well. still i'm not receiving the token.
Here's the screenshot of devise config:
And here's the screenshot of my routes for user
No need to give a full start and end URL for the dispatch request. Just try with below code and you are good to go.
jwt.dispatch_requests = [
['POST', /sign_in/]
]
I tried it but still i'm not receiving the token
And also make sure to have following code inside your user
model.
devise(
:jwt_authenticatable,
:database_authenticatable,
jwt_revocation_strategy: self
)
devise(
:jwt_authenticatable,
:database_authenticatable,
jwt_revocation_strategy: JwtDenyList
)
Instead of self i have JwtDenyList
That's fine. It should work. For me, I didn't have any relations for deny_list
so using the same user
table.
I tried both none is working
Hi @adnanmirza1 , I need the debugging information that is requested on the bug report template to be able to help you.
Change to the below code to see if it works. As far as I am concerned the route is supposed to be like the following one. I am afraid that your API routes look sneaky. Please try the following code and let me know if it helps.
scope 'api/v1' do
devise_for(
:users,
controllers: {
sessions: 'api/v1/users/sessions',
},
defaults: { format: :json }
)
end
Ah yes. You have already defined devise_for
. We cannot define twice. What you can do is, now you have to use as
keyword like below.
scope 'api/v1' do
devise_scope :user do
get 'users/sign_in' => 'sessions#new', as: :new_user_session
post 'users/sign_in' => 'sessions#create', as: :user_session
delete 'users/sign_out' => 'sessions#destroy', as: :destroy_user_session
end
end
@waiting-for-dev what else do you need from my side to help me?
Please share your route file.
Just copied your routes and pasted in mine and now it's working.
Thank You so much for all the help. <3