angular-ui / ui-calendar

A complete AngularJS directive for the Arshaw FullCalendar.
http://angular-ui.github.io/ui-calendar/
MIT License
1.49k stars 729 forks source link

eventSource is a restfull service with JWT token #355

Open razor9999 opened 8 years ago

razor9999 commented 8 years ago

my calendar has to get data from a internal service with JWT token requirement. is there any method to custom http request header? E,g

$scope.eventSource = {
    url: $scope.dataBaseServiceUrl + 'calendar',
    className: 'gcal-event', // an option!
    currentTimezone: 'UTC', // an option!,
    cache: false,

// header:{Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6Ik....'}

};
morganseznec commented 8 years ago

Hi razor9999, In order to add the access_token in the header you can try to do as below:

eventSources: [
                    {
                        url: '/api/calendar',
                        headers: {
                            'Authorization': 'Bearer' + $rootScope.access_token
                        }
                    }
                ]
hnitzsche commented 7 years ago

Don't forget the single whitespace between 'Bearer' and the token.

stephanesoares commented 4 years ago

eventSources: [ { url: '/api/calendario', headers: { 'Authorization': 'Bearer ' + jwtoken } } ],

Hello, I tried to use your example with a laravel application. My route is defined in middleware that requires authentication. If you remove the request in api works correctly