I'm trying to use tymon/jwt-auth with laravel 5.2 and I got {"error":"token_not_provided"} every time when calling http://localhost/testapp/public/api/authenticate.
this is the routes I tried!
Route::group(['prefix' => 'api', 'middleware' => 'jwt.auth' ], function()
{
Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController@authenticate');
Route::get('authenticate/user', 'AuthenticateController@getAuthenticatedUser');
});
Are you _providing a token_? Your front end must send a JWT to the server somehow (usually through headers, but query strings, route parameters, and other methods are supported). Just sharing your routes tells us little about how you accomplish this.
Also, immediately calling for help in an unrelated thread is rather impolite. Doing it in a thread that _specifically talks about the challenges of supporting a burgeoning open-source project_ is downright ironic.
I'm sorry. my bad. I needed help asap!
For the authenticate, there is no use of token right? we do authenticate to obtain a token. here it's asking for a token even for authenticate. :-/
is it because you are looking for a token in your middleware...?
jwt.auth calls authenticate which then checks for a token
Yeah! think JWTAuth middleware looking for a token!
However, I'm confused with laravel 5.2 + tymon/jwt-auth. It's worked perfectly in laravel 5.1 and configs were easy.
All you have to do is remove the jwt.auth middleware from running on your authenticate route, then it won't look for a token anymore
Okay! Um gonna check with that. but, using this code in AuthenticateController it should be refused!
public function __construct()
{
$this->middleware('jwt.auth', ['except' => ['authenticate']]);
}
Thanks guys! I got it done. and feeekkk, you were right. Thanks again and sorry for distract before.
Most helpful comment
Also, immediately calling for help in an unrelated thread is rather impolite. Doing it in a thread that _specifically talks about the challenges of supporting a burgeoning open-source project_ is downright ironic.