Aurthorization

2 posts, 0 answers
  1. Bill O'Neil
    Bill O'Neil avatar
    113 posts
    Member since:
    Nov 2004

    Posted 19 Sep 2017 Link to this post

    I would like to use client side binding to a RESTful api that requires a token in the headers for authorization.  Is this  possible?
  2. Peter Milchev
    Admin
    Peter Milchev avatar
    394 posts

    Posted 30 May Link to this post

    Hello Bill,

    The Add authentication request headers with ClientDataSource KB article demonstrates how to achieve it.

    var $ = $ || $telerik.$;
    var old_mapTransport = Telerik.Web.UI.RadClientDataSource.prototype._mapTransport;
     
    Telerik.Web.UI.RadClientDataSource.prototype._mapTransport = function () {
        var transport = old_mapTransport.call(this);
     
        transport.read.beforeSend = beforeSendHandler;
        transport.create.beforeSend = beforeSendHandler;
        transport.update.beforeSend = beforeSendHandler;
        transport.destroy.beforeSend = beforeSendHandler;
     
        return transport;
    }
     
    function beforeSendHandler(xhr) {
        xhr.setRequestHeader('customheader', 'custom header value');
    }

    Regards,
    Peter Milchev
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top