Page 2 of 6

Oauth tutorial - Cannot find hostname in file

Posted: Wed Aug 20, 2014 11:29 am
by Kateryna Grynko

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?


Oauth tutorial - Cannot find hostname in file

Posted: Wed Aug 20, 2014 3:20 pm
by Alexis Revue

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;
},


Oauth tutorial - Cannot find hostname in file

Posted: Thu Aug 21, 2014 8:01 am
by Kateryna Grynko

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?


Oauth tutorial - Cannot find hostname in file

Posted: Fri Aug 22, 2014 12:22 am
by Alexis Revue

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.


Oauth tutorial - Cannot find hostname in file

Posted: Wed Aug 27, 2014 6:31 pm
by Kateryna Grynko

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).


Oauth tutorial - Cannot find hostname in file

Posted: Thu Aug 28, 2014 12:15 pm
by Alexis Revue

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?


Oauth tutorial - Cannot find hostname in file

Posted: Mon Sep 01, 2014 11:13 am
by obullei

Hello!

Please pay your attention that you are testing your application on iOS, but you have added plugin to the Android folder.


Oauth tutorial - Cannot find hostname in file

Posted: Mon Sep 01, 2014 11:23 am
by Alexis Revue

Hello Arina,

I know, it's in both folders so it can work on Android and iOS.


Oauth tutorial - Cannot find hostname in file

Posted: Wed Sep 03, 2014 10:38 pm
by Alena Prykhodko

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.


Oauth tutorial - Cannot find hostname in file

Posted: Fri Sep 05, 2014 6:48 pm
by Evgene Karachevtsev

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