Alexis Revue
Posts: 0
Joined: Wed Jul 02, 2014 4:28 am

Oauth tutorial - Cannot find hostname in file

Hi,

I tried to follow the Oauth tutorial (http://devcenter.appery.io/tutorials/...) but a get an error on my iphone and i have no idea how to diagnose it:

I get this error when I try to connect with google:
Cannot find hostname in file:/// from static
code: InvalidHeader
message: Cannot find hostname in file:/// from static

I've already checked the following:

  • "Try auth" works on oauth.io

  • Device ready script looks OK

  • oauth.js has been uploaded

  • oauth.io phonegap plugin has been uploaded and modified

  • cordova_plugins.js has been modified

    I'm lost :-(

Alexis Revue
Posts: 0
Joined: Wed Jul 02, 2014 4:28 am

Oauth tutorial - Cannot find hostname in file

Hi,

If I'm right,

A. For a web app, i need a JS OAuth.js (oauth-js version instead of the oauth-phonegap)

B. For a mobile app, i need a oauth-phonegap in ANDROID OAuthApp Assets www files resources lib plugins.

In my case since it's a mobile app, i just have the plugin(B) and I don't put the JS(A).

However, according to the tutorial, when I click on a login button, I should run the following script.

try
{
OAuth.initialize('PT045KHI0Nx280Yd397CbloE2BU');
}
catch(err)
{
alert('initialize error' + err);
}

But, if I'm right, OAuth is not declared the plugin (B) but in JS (A).

So:

  • If want to use Oauth.io for a mobile App, do I need the OAuth.js (§Add the OAuth.io JavaScript of the tutorial) ?
  • If not, when I click on the button, what is the JS script I should run ? do I have to use OAuth object or another one?
Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Oauth tutorial - Cannot find hostname in file

Hello Alexis,

You can use OAuth.io for web applications, as it is shown here: https://oauth.io/docs/api-reference/c...
Just add the JS from here: https://github.com/oauth-io/oauth-js/...

Alexis Revue
Posts: 0
Joined: Wed Jul 02, 2014 4:28 am

Oauth tutorial - Cannot find hostname in file

Hi Evgene,

Thank you, I checked the doc and I'm still confused.
Since I want to build a mobile app instead of a web app,

  • is "https://github.com/oauth-io/oauth-js/..." oauth.js the right JS?

  • where should I copy it? as a JS file in the project tree or as a plugin in source tab?

    When I try to use Oauth to connect with to twitter

  • it works when I test in a web browser

  • it fails when I test in a mobile:
    "message: Cannot find hostname in file:/// from static"
    or
    initialize errorTypeError:'undefined' is not a function (evaluating 'OAuth.initialize(...'
    depending on what I put in the folder Javascript of Project tree.

    In the first case, according to what I read, I'm not using the right JS, in the second case, I'm not sure OAuth is well declared...

Alexis Revue
Posts: 0
Joined: Wed Jul 02, 2014 4:28 am

Oauth tutorial - Cannot find hostname in file

lil update:

I've made some changes and tested different cases:

With Mobile Preview:

  • Login with oauth.io to Google: OK

  • Login with oauth.io to Twitter: OK

    Android

  • Login with oauth.io to Google: OK

  • Login with oauth.io to Twitter: KO, nothing happens

    iOS

  • Login with oauth.io to Google: OK (kind of, blank screen after login instead of the app)

  • Login with oauth.io to Twitter: KO, nothing happens

    Twitter oauth test on https://oauth.io/ OK

    The JS of the login button for twitter is the following:
    OAuth.initialize(my_oauth_key);

    OAuth.popup('twitter').done(function(result) {
    alert(result);
    console.log(result);
    // do some stuff with result
    });

    result.me().done(function(data) {
    alert(data);
    // do something with 'data', e.g. print data.name
    });

    What do you think could be wrong with twitter oauth.io login on mobile knowing that the scripts works with google (web browser and mobile) and with twitter (web browser)?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Oauth tutorial - Cannot find hostname in file

HI Alexis,

Please check if there are any errors in console for Twitter using Weinre: http://devcenter.appery.io/documentat...

Alexis Revue
Posts: 0
Joined: Wed Jul 02, 2014 4:28 am

Oauth tutorial - Cannot find hostname in file

Hi,

Thank you, I was able to fix part of the issue.

I had to modify:

  • the js that calls OAuth.popup for twitter

  • the OAuth.io plugin that redirected to localhost

    Now, I have a (last) issue when I test on mobile device:
    once I log in with google or twitter, instead of closing the inapp browser and go back to the app, a new inapp browser window is opened.

    I tried with 1.2 librairies, I still have this issue.

    Is it a known issue? Do you know how could I fix it?

    http://devcenter.appery.io/tutorials/...

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Oauth tutorial - Cannot find hostname in file

Hi Alexis,

Could you please clarify your device and OS version?

Alexis Revue
Posts: 0
Joined: Wed Jul 02, 2014 4:28 am

Oauth tutorial - Cannot find hostname in file

Hi Katya, Os 7.1.2 and iPhone 5.

Return to “Issues”