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.

Sending authorization header along with a Restangular call - Not global??

See original GitHub issue

Hi there,

I have implemented 2 Restangular services, 1 is the pure Restangular that i will use to send across my token and the other is what I have called AuthRestangular where I need to build the Authorization header.

I did get it to work… using the following but I think this is changing it on a global scale, which i believe is going to affect my standard Restangular injected variable.

            var encoded = base64.encode('userb:userb');
            $http.defaults.headers.common.Authorization = 'Basic ' + encoded;

I did try the following new method but I think i am calling it wrong…

           AuthRestangular.setDefaultHeaders({'Authorization': 'Basic ' + encoded });

It doesn’t give me an error but it doesn’t seem to be sending the header across, my rest service never detects it.

Any ideas ? I can’t seem to find any examples.

Thanks

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:26 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
yaoelvoncommented, Aug 5, 2016

The RestangularProvider.setDefaultHeaders will work for requests made via Restangular only. While $http.defaults.headers.common will work on all requests made via $http including Restangular requests, because Restangular also use $http behind the scene.

0reactions
raihanoriumcommented, Aug 14, 2016

No solution yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular - Bearer token not sent in request header on API calls
For user Authentication the application requests and receives a bearer token from Azure AD. It should then transmit this token with each REST ......
Read more >
Using Access Token to Secure Angular Calls to Web API
Let's learn how to extract Access Token from the user object and use it inside the Angular request to access prtected API resources....
Read more >
ng2-restangular-fix-queryparams - npm
I need to send Authorization token in EVERY Restangular request, how can I do this? I need to send one header in EVERY...
Read more >
Posting, Deleting, and Putting Data in Angular | Pluralsight
An HTTP request is a packet of information which is transferred from source to destination and termed as Client-Server respectively.
Read more >
Cloud API reference | Reference Documentation - Particle docs
To send a custom header using curl, use you the -H flag. The access token is called a "Bearer" token and goes in...
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