Tuesday, 30 May 2017

I want to get token using http in Angularjs from IBM?

I am trying to get token from ibm watson using my username,password and url. Here is my curl Command that is working fine

curl --basic --user 04ba08c6-4505-4125-aa04-e89350fc28ae:1476c62b-6149-429a-89f7-a546df89caf5 https://ibm-watson-ml.mybluemix.net/v2/identity/token

but when i try it in angularjs it gives me error

404 Not Found

Here is my angular code

    user = "04ba08c6-4505-4125-aa04-e89350fc28ae";
    pass  = "1476c62b-6149-429a-89f7-a546df89caf5";
    aurl  = "https://ibm-watson-ml.mybluemix.net/v2/identity/token";
    var headers = {"Authorization": "Basic " + user+":"+pass};
    $http.get(aurl, {headers: headers}).then(function (response) {
     alert(response.data);
     //handle data
    });

Please let me know whats the error in my code?



via Farman Ali

No comments:

Post a Comment