0

I'm running into the following error when trying to post to my identityserver using "https://localhost:44333/identity/connect/token" from my angularjs authService, but when I post from Postman or Fiddler all works fine.

enter image description here

I have self created a certificate which I imported and so when I navigate to https://localhost:44333/identity in my browser all is good.

enter image description here

What I could gather from googling around was that it had something to do with certificates, but I can only find topics on node.js. I'm trying to authenticate from a angularjs service to an IdentityServer3 which I selfhosted on the above url using owin.

The following is what my angulajs login code looks like:

var _login = function (credentials) {

    var user = { grant_type: 'password', username: credentials.userName, password: credentials.password, scope: 'salesApi' }

    var urlEncodedUrl = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': 'Basic ' + base64Encoded
    };

    console.log(base64Encoded);

    $http.post(serviceBase + 'connect/token', { headers: urlEncodedUrl }, { data: user }).success(function (data, status, headers, config) {

        localStorageService.set('authorizationData', { bearerToken: data.access_token, userName: credentials.userName });

        _authentication.isAuth = true;
        _authentication.userName = credentials.userName;
        _authentication.bearerToken = data.access_token;


    }).error(function (err, status) {
        console.log(err);
        _logOut();
    });
};

Any ideas on what I'm missing or how to solve this error?

UPDATE: Is this actually a ripple emulator or cordova issue?

Bracher
  • 651
  • 10
  • 24

2 Answers2

-1

I had the same problem and resolved get API to work with a real host. Seems to be a issue with Ripple.

  • Can you be more explicit and explain what you mean by _and resolved get API to work with a real host_ . Your answer is hard to understand as it is, thanks. – Yacc Oct 27 '15 at 23:33
  • 1
    Sorry about that. I was facing same problem developing using Visual Studio 2015 + Apache Cordova (Ripple) + Web Api and I was facing same issue as you trying to get the token. I also noticed that using Ripple to test was returning that error then what I did was to move my webapi to azure host, got a real ssl, redirect my cordova app to new host and then that message gone. I really believe this is a ripple issue. Sorry if my first answer is confusing. If you want more info please ask me. I will be glad to help. – user3720916 Oct 28 '15 at 00:23
-1

If anyone is still having the same issue, it may be worth trying my Ripple solution at Using the Apache Ripple emulator with a self signed SSL certificate

I'll add the steps of my answer from the above SO question to prevent further downvotes:

  1. Create a shortcut to run Chrome with the --disable-web-security flag set. If further information is required see my answer at Visual Studio, Ripple Emulator and CORS/Cross Domain Ajax
  2. Start Ripple using either the command line or Visual Studio
  3. Start an instance of Chrome using the shortcut from 1.
  4. Browse to your Ripple url and issue your request over HTTPS
  5. This will fail and the dev tools console will show POST https://mydomain:port/api_endpoint net::ERR_INSECURE_RESPONSE
  6. In a new tab browse to your https://mydomain:port url
  7. This will result in a "Your connection is not private" web page. Click on "Advanced", and then on "Proceed to https://mydomain:port (unsafe)" to accept the self signed SSL
  8. Now back on the Ripple tab try issuing your request again and it should succeed.
Community
  • 1
  • 1
Chris
  • 233
  • 2
  • 13
  • Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Tunaki Feb 05 '16 at 09:24