How to consume REST service with Basic Authentication
See original GitHub issueHi All,
I have java REST services and consumer in Angularjs 1.3. Services are JSON based and expect BASIC authentication (username-password). In AgJs 1.3, I used Base64 factory code (found on google) for creating basic authentication token from username and password and able to consume services SUCCESSFULLY.
I read HTTP class in AgJs 2.0 documentation but I didn’t find any information about basic authentication.
Could anybody please provide sample code to consume REST services in Angularjs 2.0 using BASIC authentication?
Thanks in advance! Best Regards!
My AgJs 1.3 code:
var url = “http://x.x.x.x:xxxx/data/” + number;
$http.defaults.headers.common['Authorization'] = 'Basic ' + Base64.encode('username' + ':' + 'password');
$http.defaults.headers.common['Content-Type'] = 'application/json';
$http({ method: 'GET', url: url }).
success(function (data, status, headers, config) {
alert(data);
}).
error(function (data, status, headers, config) {
alert("error: " + data);
});
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Java restful webservices with HTTP basic authentication.
1) Username and password are combined into a string "username:password" · 2) The resulting string is then encoded using Base64 encoding · 3)...
Read more >How do we consume rest api with Http basic authentication in ...
1 Answer 1 ; = new HttpGet ; // Combine the user and password pair into the right format String auth ; =...
Read more >Basic Authentication with the RestTemplate - Baeldung
In this tutorial, we'll learn how to use Spring's RestTemplate to consume a RESTful Service secured with Basic Authentication.
Read more >Add Basic Authentication to an Exposed REST API
In the Logic tab, open the Integrations folder. Select the exposed REST API you want to change and set its "Authentication" property to...
Read more >How to use Basic Authentication with Rest Template in Spring ...
Basic authentication provides one of the ways to secure REST API. It's not the most secure way compared to OAuth or JWT based...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, i am calling switch API’s for that i need to login to it first from postman i am using Authorization type basic and setting username ans password , i want to implement this in code i am using Angular 6.
please help me to get solution
Thanks in advance Tanaji
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.