Here is simple code snippet to add authorization header in an ajax call:

 

$.ajax({
            url: your URL,
            type: 'GET',
            dataType: 'json',
            headers: {
                'Authorization': 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJEdTFPeTBJaXh0Sy1fLU8za1FIR2pTekllRC11c1czVEc5MkVWZVJhLW5RIn0.eyJqdGkiOiI2YzgwZWUzYi01ZjZmLTRjZDUtYjJiMC1kNjFlZjgxMGIzY2MiLCJleHAiOjE1MTMwMDc3NDIsIm5iZiI6MCwiaWF0IjoxNTEzMDA3NDQyLCJpc3MiOiJodHRwOi8vYXV0aGRldjo4MDgwL2F1dGgvcmVhbG1zL1NESUVQIiwiYXVkIjoic2VjdXJpdHktYWRtaW4tY29uc29sZSIsInN1YiI6ImFjNTViMGZiLWFjZDgtNGQ2ZC1iZDg2LWJkNWZkMjQ5MDg5YiIsInR5cCI6IkJlYXJlciIsImF6cCI6InNlY3VyaXR5LWFkbWluLWNvbnNvbGUiLCJub25jZSI6IjU3ZTE3MTNhLWU3ZWQtNDFlMi04N2YzLThhYWU1YzU5NjkwYyIsImF1dGhfdGltZSI6MTUxMzAwNTg2OSwic2Vzc2lvbl9zdGF0ZSI6IjhlYzZjZDQ2LTE3YzctNDZjOS05N2UwLTQ5MGQ2ZTlhM2E3ZiIsImFjciI6IjAiLCJhbGxvd2VkLW9yaWdpbnMiOltdLCJyZXNvdXJjZV9hY2Nlc3MiOnt9LCJuYW1lIjoiU0RJIEFkbWluIiwicHJlZmVycmVkX3VzZXJuYW1lIjoic2RpYWRtaW4iLCJnaXZlbl9uYW1lIjoiU0RJIiwiZmFtaWx5X25hbWUiOiJBZG1pbiIsImVtYWlsIjoic2RpYWRtaW5Ac21hcnRkZXN0aW5hdGlvbnMuY29tIn0.T8cRQTACjcT6xNWrPY7NIu6lwSliSoyR2WOf8CK6fA_lRoFmzwOddX-1oOf6WIGMVgrAROl-TVHW2wu3z9oW2CAYoBNeRSq5Cv6Bqhaf7KOaG8dpD4Ck0mwLAIhG77x4Y8wPAms5h-BzzWrpS8pM3J8Uda8O_t4cvsVuOx0bwGrBUVebmOBJbVlY2N6_iU7GQ6MRjLrDFiuiNPklERHS44V_622l4IfsyKdnWb_u9B5KuqZt9pDluvjfNG6B2xxsXfJjTmuSHWKPkPRXWGSx87fXBFLW1sZH6MNNpndsBLrxOPiN5PPYwxLeCTu1A_UEWgnecUG6uZJJtc9iJq4dLA'
                
            },
            contentType: 'application/json; charset=utf-8',
            success: function (result) {
               // CallBack(result);
            },
            error: function (error) {
                
            }
        });

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>