This is a migrated thread and some comments may be shown as answers.

Kendo UI and JWT

1 Answer 342 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
danny
Top achievements
Rank 1
danny asked on 03 Feb 2015, 03:57 AM
I am developing single page application with angularJs, the application uses JWT Authorization headers to authenticate with my MVC web API. I recently integrated Kendo into the application but i noticed that my AngularJs request interceptor is not able to intercept calls generated from kendo grid .

Is there a common place where i can intercept http requests initiated from Kendo grid and other kendo components . so that i can add Authorization Header ?

here is my inerceptor
['$httpProvider', function ($httpProvider) { $httpProvider.interceptors.push('authInterceptorService'); }]


function addToken(config) {

            var token = tokenStoreFactory.getToken();
            if (token) {
                config.headers = config.headers || {};
                config.headers['Authorization'] = 'Bearer ' + token;
            }
            return config;
        }

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 05 Feb 2015, 06:47 AM
Hello Daniel,

Kendo Grid uses jQuery's Ajax method to performs XHR requests. And all the settings that are passed to the jQuery ajax method should be defined on the transport.read configuration (same goes for the Update/Create/Destroy operations).

Here is an example how you can configure your DataSource to add extra headers with information (via the beforeSend event).

http://www.telerik.com/forums/how-to-set-authorization-header-for-transport-read#Ds6e3JkOXEKOB24yFTggcg

Kind Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
General Discussions
Asked by
danny
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or