witoldsz / angular-http-auth

MIT License
2.38k stars 417 forks source link

Updating deferred requests #30

Closed Astrac closed 11 years ago

Astrac commented 11 years ago

I'm using this interceptor to integrate with google authentication; this is done simply by listening to the "login required" event that will be broadcast when google answers a request with a 401 response. The event handler uses google APIs to get a token and invokes the loginConfirmed method in the authService.

The problem I'm facing is that this causes an infinite loop, since the requests will be retried but their configuration won't include the token and they will fail again with status 401. I'm thinking about adding a parameter to the loginConfirmed method to pass in a "http updater function" that will be invoked on each configuration object of the httpBuffer before retrying the request (so that in my case I can set the Authorization header).

Does this sound like a viable solution? Are you interested in such a patch or does anyone have a better idea to get around this issue?

Thank you!

witoldsz commented 11 years ago

Moving further conversation to #31.