In github, there's this section where you can do basic auth... If I was using curl, this would look like:
$ curl -u <username>:<token> https://api.github.com/user
How do I turn that into http request if I were to do it in angular?
I finally managed to solve it. I based my answer from icodeya.
function authenticateUser(username, authtoken) {
var url = "https://api.github.com/user"
var credentials = btoa(username + ':' + authtoken);
var authorization = {'Authorization': 'Basic ' + credentials};
var header = { headers: authorization }
return $http.get(url, header)
.then( function(response) {
function() { //do something here. }
}
);
}