{
“user”: {
“id”: 1,
“token”: “yourSecretTokenComingFromTheDatabase”
}
}
Than you can use this token
to authenticate yourself for accessing urls what requires authentication. The token
should be sent in a request header named Token
(or what you set in your config/apiTokenAuthenticator.php
file).
How does it work? When i set JWT Token it return user data but if i go with this plugin ApiTokenAuthenticator then i get nothing in response just error status show 401 authentication require for this action, why?
$token = ‘wvOgZIKAhku8K5sUXBVdz4NCs0tj0ahery8akPRJIDs5WyitXhcAg’;
$params = http_build_query([‘profile[first_name]’=>‘bar’]);
$options = stream_context_create([‘http’=>[
‘method’=>‘GET’,
‘header’=>“Content-Type: application/x-www-form-urlencoded\r\n”.'Authorization: Bearer '.$token,
‘content’=>$params
]]);$auth = ‘http://localhost/skyweb/api/v1/usuaria/logout.json’;
$user = ‘http://localhost/skyweb/api/v1/users.json’;$api = file_get_contents($user,false,$options);
print_r($api);
the above code send request to cakephp Application for fetch information on the token basis but it does not work but JWT token return everything on demand.
Application.php