Restws authentication How can I login to my Drupal in API way and use the rest ws module with API calls? 

For example, I have a user with name test. I want to login with test user then use API calls with something like a token or identity (I don't know what) and make Drupal recognize user in :

global $user;


How is it possible?

I tried to post username and password to /user/login path  and get token from /restws/session/token

It returns something like this :

emGevPKZl9aLe90tOJ1ZK9rnp--6BMeNV3RP27aqcsY


but when I use it in header parameters with name X-CSRF-Token it does nothing.
You would probably have an easier time using the services module it's better supported and used far more than the restws module. It supports several types of web service calls including RESTful.

SERVICES:


  A standardized solution of integrating external applications with Drupal. Service callbacks may be used with multiple interfaces like REST, XMLRPC, JSON, JSON-RPC, SOAP, AMF, etc. This allows a Drupal site to provide web services via multiple interfaces while using the same callback code.