I have a backend with drupal !
Using Drupal Services to interact with. which provides a rest server !
Created endpoint named ‘api’
Following sequence works in normal browser or any http client like postman :-
-
example.com/api/login (works)
- api sends back user data (token,session id, session name etc).
- Further any request i make , i send token as X-CSRF-Token (all requests work).
- i can even logout the same session with the token received before !
IN IONIC APP :-
I can login and i am also able to store user data (token, session data etc). in localstorage after login
here’s the difference in app :-
When i send same token back to server while making a request ( say logout)
Server’s Response is “User is not Logged In.”
Why does this happen ?
PLEASE HELP !
Help is appreciated !
Update :-
After logging in i tried getting the current token from the server , and it was different from the one i saved after successfully logging in !
every time different token is received ! Some one help with this authentication issue …
Hi @Sumeet123!
Its because you forgot to set the session data in your cookie
Also hav painful days with this. (btm postman / chrome in general sets the coocies automatically )
Because handling drupaly API is not the easyest thin i created a angular repo to handle a lot of requests. I also created a authentication service which makes your suth flow a copy paste thing.
check it out! => ng-drupal-7-services
I also created an IONIC DRUPAL DEMO
@BioPhoton Thats great !
cant wait to try after giving up wih that session auth i cosidered basic auth which anyhow was going to work !
I am surely trying that ! thanks for the help and appreciate