Search code examples
oauth.io

Phonegap build app with oauth.io, not working


I'm trying to get the OAuth.io system working in my app. I normally develop my apps in my browser first, and then port them over into the Android/iOS apps, using Phonegap Build. Here is the JS I'm using: (I've downloaded oauth.min.js, and am including that fine);

$('#facebook-login').click(function() {
    OAuth.initialize('xxxx_my_key_here_xxxx');
    OAuth.popup('facebook').done(function(result) {
        console.log(result)
        alert("all good");
    })
    .fail(function (err) {
        alert("oops, we got an error!");
        console.log(err);
    });

    return false;
});

I then try it from my test domain, and get:

Error: Origin "http://testdomain.com.nmsrv.com/steampunk/login.html" does not match any registered domain/url on oauth.io

Which makes sense, as I had to set the domain to yours:

enter image description here

If I convert it into a "proper" app, and then try running in an emulator, I get this error:

enter image description here

Is there no way I can run this both as a web-app (for developing), and also in the phonegap app? (I can't get either working yet - which is annoying - as I've spent most the day on it)

UPDATE: Ok, so I found the "Domains & URLs whitelist", and added my test domain in there -all good now - I get a correct response back. However that won't work on the app itself, as file:// would be the referrer. What would I put there?


Solution

  • As you've mentionned, you need to whitelist your domain testdomain.com.nmsrv.com in the OAuth.io Dashboard to test the authorization in a browser. For mobile SDKs (Phonegap, iOS, Android), you don't need to whitelist the file:///, OAuth.io handle it for you.