Hi Alexis,
Yes, this is a known issue. It will be fixed in the nearest release. But it is not reproducible in libraries 1.2. Could you please double check you do everything correctly?
Hi Alexis,
Yes, this is a known issue. It will be fixed in the nearest release. But it is not reproducible in libraries 1.2. Could you please double check you do everything correctly?
I think I have the same issue with 1.2 libraries.
I put the JS & plugin code below if it helps.
With 2.0:
alert of twitter name OK + new inappbrowser (instead of resuming the app)
With 1.2:
alert of twitter name KO + new inappbrowser (instead of resuming the app)
I'm pretty confident it's a new inappbrowser coz I have API calls working with the app and not with in-app browser (even though I don't actually know why btw...).
JS Code:
OAuth.initialize('PT045KHI0Nx280Yd397CbloE2BU');
OAuth.popup('twitter', function(error, result) {
if (error) {
alert('error : ' + error); // do something with error
return;
}
localStorage.setItem('twitter_oauth_token', result.oauth_token);
localStorage.setItem('twitter_oauth_token_secret', result.oauth_token_secret);
result.get('/1.1/account/verify_credentials.json').done(function(data) {
console.log(data);
alert('Hello ' + data.name);
});
});
Plugin Code:
popup: function(provider, opts, callback) {
var wnd, wndTimeout;
if ( ! config.key)
return callback(new Error('OAuth object must be initialized'));
if (arguments.length === 2) {
callback = opts;
opts = {};
}
opts.state = create_hash();
opts.state_type = "client";
client_states.push(opts.state);
var url = config.oauthd_url + '/auth/' + provider + "?k=" + config.key;
url += '&redirect_uri=http%3A%2F%2Fappery.io%2Fapp%2Fview%2F {** Appery Token } %2F { Page **}';
url += "&opts=" + encodeURIComponent(JSON.stringify(opts));
wndTimeout = setTimeout(function() {
try {
wnd.close();
} catch(e) {
return;
}
callback(new Error("Authorization timed out"));
}, 1200 * 1000);
Code: Select all
wnd = window.open(url, '_blank', 'location=yes,toolbar=yes');
wnd.addEventListener('loadstart', function(ev) {
if (ev.url.substr(0,17) !== "http://localhost/")
return;
if (wndTimeout) clearTimeout(wndTimeout);
var results = /[\\#&]oauthio=([^&]*)/.exec(ev.url);
wnd.close();
if (results && results[1]) {
opts.data = decodeURIComponent(results[1].replace(/\+/g, " "));
opts.callback = callback;
opts.provider = provider;
sendCallback(opts);
}
else
callback(new Error("unable to receive token"));
});
return wnd;
},
HI Alexis,
Could you please share the app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a, tell its name and post steps to reproduce the issue?
Hi Katya,
App shared :"Test App".
iPhone 5S
Lib: 1.2
"Button" - "Twitter" - login with twitter (authorize app) - "localhost" opened in the twitter window instead of closing the inappbrowser.
alert('Hello ' + data.name); is not processed.
Page : Oauth
Plugin : IOS/Test_App/Test_App/Ressources/www/project/files/resources/lib/com.phonegap.plugins.oauthio
Thank you, feel free to ask if you need more information.
Hi Alexis,
You added plug-in for both browser (JS asset 'oauth') and PhoneGap - on source tab.
Could you please try deleting browser plug-in? Or you could ad it if this is not a hybrid app (you can check this in JS asset 'oauth' code).
Hi Katya,
I've deleted the browser plug in but I still have the same issue.
I don't need it to work on browsers, mobile is fine.
What else do you think I could try?
Hello!
Please pay your attention that you are testing your application on iOS, but you have added plugin to the Android folder.
Hello Arina,
I know, it's in both folders so it can work on Android and iOS.
Hello Alexis,
Sorry, no news yet. We were able to reproduce the problem. Looking for solution.
We'll let you know as soon as have updates.
Hello Alexis,
The problem may be in fact that you changed the library version after made changes in cordova_plugins.js
Please delete this file, make Undo all changes for the IOS folder and again make the desired changes to the file cordova_plugins.js