oauth-io / oauth-phonegap

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

Invalid format state:invalid or expired Error #28

Closed sukanyasubramanian closed 10 years ago

sukanyasubramanian commented 10 years ago

We are using oauth plugin in our application for login.I send a login request to google plus using valid credentials.Before this process is completed a second request is triggered by tapping on the signin button again,the following error is thrown.

Error code in iPad console :2014-05-08 16:25:30.116 rpad_plos[2270:907] webView:didFailLoadWithError - -999: The operation couldn’t be completed. (NSU RLErrorDomain error -999)

william26 commented 10 years ago

Hi,

Did you add the <access origin="[URL]"/> tags in the config.xml file? The "NSURLErrorDomain" seems to be linked with the fact that one of the APIs domain or OAuth.io's site is not trusted.

Does that happen when you call the popup method?

Also, if you want to have the errors returned by the SDK in a more direct way, you can use Weinre which will give you a console similar to Google Chrome's.

Thanks for your feedback, Hope that helps :)

sukanyasubramanian commented 10 years ago

Hi,

I have set permission to all the domains in the config.xml by adding .But still I am getting same error when I tap on the signin button. We are using GapDebug and safari debugger for debugging purpose and app level logs are only printed in the console.Since signin is happening in the inapp browser so we couldn't able to capture the logs in console.

Thanks, Sukanya

william26 commented 10 years ago

If I understand well, you send two request to login to Google Plus, is that right? Are you using the popup method to do that? Normally, you should only call the popup once during the app runtime, and reuse the response to perform requests to the API (using the .get(), .post(), .put(), .patch(), .del() and .me() methods).

The flow should look something like this:

// 1. initialization
OAuth.initialize('your_key');
// 2. authentication
var api = undefined;
OAuth.popup('google_plus')
    .done(function (response) {
         api = response;
    })
    .fail(function (e) {
        console.log(e);
    })

// 3. requests (for example using the me() method)

if (api) {
    api.me()
        .done(function (user) {
            console.log(user.name);
        })
        .fail(function (e) {
            console.log(e);
        });
}

Hope this helps