javascript - Angular request api along with token -


in angular application, function return result of:

{"error":"token_not_provided"} 

the function is

(function() {      'use strict';      angular         .module('authapp')         .controller('usercontroller', usercontroller);      function usercontroller($http,$auth,$window) {         var vm = this;          vm.users;         vm.error;          vm.getusers = function() {             //console.log($window.sessionstorage.token);             // request hit index method in authenticatecontroller             // on laravel side , return list of users             $http.get('api/getuser').success(function(users) {                 vm.users = users;              }).error(function(error) {                 vm.error = error;             });         }      }  })(); 

the authentication using facebook successful, , can token, if request restricted api, server return above error message.

my route

route::get('/', function () {     return view('index'); });  route::group(['prefix' => 'api'], function() {     //route::resource('authenticate', 'authenticatecontroller', ['only' => ['index']]);     route::get('getuser', 'authenticatecontroller@index');     route::post('authenticate', 'authenticatecontroller@authenticate'); }); 

using postman result restricted api works, using browser give me above error.

thanks.

i assume talking jwt? try adding .htaccess file:

rewritecond %{http:authorization} ^(.*) rewriterule .* - [e=http_authorization:%1] 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -