question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unauthorized Requests

See original GitHub issue

I’m using angular-datatables with server-side processing and Angular http interceptors to handle session expiring. It works with the requests made to the API normally, but the requests made by Datatables are not intercepted, and I just can’t get any information from the server saying that the user has to log in again.

Instead, jQuery logs on the console a 401 error, but Angular does not catch it, and the application gets broken.

Any idea here? I think that a lot of people can have the same trouble, regarding that we use Angular with an API providing the data.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
rcevscommented, Apr 14, 2016

I managed to solve this issue including the token inside the authorization header and adding an error function to be called if the request fails.

.withOption('ajax', {
    headers: {
        Authorization: 'Bearer ' + localStorage.getItem('satellizer_token')
    },
    dataSrc: 'data',
    url: url,
    type: 'GET',
    error: function () {
        // remove the token from localStorage and redirect to the auth state
    }
})

Please let me know if this also works for you.

1reaction
ahmadhsalimcommented, Oct 31, 2015

I’m having the exact same trouble and I want to skip the error handling of Datatables when status code is 401. How to do it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to deal with 401 (unauthorised) in python requests
What I want to do is GET from a site and if that request returns a 401, then redo my authentication wiggle (which...
Read more >
How to Fix a 401 Unauthorized Error? - GeeksforGeeks
The 401 Unauthorized Error is an HTTP status code error that represented the request sent by the client to the server that lacks...
Read more >
401 Error: 5 Ways to Troubleshoot and Fix It - Hostinger
The 401 Unauthorized error is triggered by unauthenticated requests made to a WordPress web server. Learn how to identify and fix the issue....
Read more >
How to Quickly Fix the 401 Unauthorized Error (5 Methods)
The 401 (Unauthorized) status code indicates that the request has not been applied because it lacks valid authentication credentials for the ...
Read more >
401 Unauthorized Error: What It Is and How to Fix It
The 401 Unauthorized Error is an HTTP response status code indicating that the client could not authenticate a request.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found