Ad

JWT: Getting Token Manually

- 1 answer

I'm using jwt-auth for laravel, and angular-js on client side.

This is my typical http request:

.controller('LoginController', function($scope,$rootScope ,$auth, $state, $http, $timeout) {
    $http.get('api/loggedIn/getMe').success(function(data) {
                //do stuff
            }).error(function(error) {
                //do stuff
            });
    })

Every time i send $http request the token side is done automatically, but I want to make one request without using $http, so I need to include my jwt-auth token in headers manualy. (that's because I want to use Dropzone for file upload).

I have something like this:

Dropzone.options.myDropzone = {
    sending: function(file, xhr, formData) {
        // Pass token
        xhr.setRequestHeader('Authorization', 'Bearer: ' + /*This is where I want to put my token*/);
     }
};

Edit: this is screenshot from firebug:enter image description here

Edit: I figured out that satelizer does that nice thing for me, so $auth.getToken() did the trick.

Ad

Answer

I figured out that satelizer does that nice thing for me, so $auth.getToken() did the trick.

Ad
source: stackoverflow.com
Ad