oauth-io / oauth-phonegap

OAuth.io plugin for Apache Cordova/PhoneGap
195 stars 69 forks source link

Seems to work but then my response is NULL #67

Closed oliverkaiser closed 8 years ago

oliverkaiser commented 8 years ago

Trying to get it working with google login on iOS and Android through an appgyver steroids application. On android I get the popup and after the login I get an application alert:

# Application Error
The server refused the connection. (http://localhost/#oauthio=.........)

the URL is followed by status and access token data. So it seems to work but is not catching the data properly.

On iOS there is no alert and my view just closes.

OAuth.initialize('x');
OAuth.popup('google',{},function(result) {
    console.log(result);
})

Ideas are welcome :) I already setup the redirection urls at my google api console.

thyb commented 8 years ago

You can do the authorization using the callback method:

OAuth.popup('google', function(error, result) {
    // the result is the second argument, the first one is the error
});

or using the promise method (better in my opinion)

OAuth.popup('google').done(function(result) {
   console.log(result)
}).fail(function(error) {
   console.log('catch error', error)
})

As you put result in first argument (with the callback method), it's in reality the error that you try to console.log (which is null)