Page 1 of 1

Closing an in app browser during oAuth

Posted: Fri Nov 21, 2014 1:55 am
by DaveVockell

I am doing an oAuth with a third party service. I am currently opening an inapp browser, and when I complete the auth I want to close the view. What code do I put in the redirect_url html to close the browser and return to the app?


Closing an in app browser during oAuth

Posted: Fri Nov 21, 2014 2:12 am
by Yurii Orishchuk

Hi Dave,

Here is an example of such code:

pre

//Open inApp browser.
var ref = window.open(url, '_blank', 'location=no');

//Make some delay:
var onDelay = function(){
//Close inApp browser.
ref.close();
};
window.setTimeout(onDelay, 10000);

/pre

Regards.


Closing an in app browser during oAuth

Posted: Fri Nov 21, 2014 9:12 am
by DaveVockell

Thanks -- I see how that might work in the page that launches the inapp browser.

i have a redirect.php url for my oAuth and I want it to execute

If (oAuth fail) then error message

if (oAuth success) then close this inapp browser

That would require code in the redirect.php, not in the page that launches the inapp. Any idea how to do that?


Closing an in app browser during oAuth

Posted: Sat Nov 22, 2014 1:01 pm
by Alena Prykhodko

Hello,

Please provide detailed app workflow in steps.


Closing an in app browser during oAuth

Posted: Thu Jul 02, 2015 7:28 am
by Deon

I have the same issue. It is basically opening a 3rd party payment gateway that then redirects to a payment successful page. This window needs to be closed to return back to the App.

You cannot do a window.close(); from the window itself. It has to come from the app. From what I could see you need to use the eventlistner. Not sure if this should be server side or clientside though?

Does anyone got a solution to this?

Thx


Closing an in app browser during oAuth

Posted: Tue Jul 07, 2015 10:56 pm
by Yurii Orishchuk

Hi Deon,

Please specify details about your implementation.

Where you load 3rd party site?

You need to use inApp browser for this goal.

In this case you can open site with code(from app context):

pre

var win = window.open("http://google.com/", "_blank");

/pre

And close it with code:

pre

win.close()

/pre

You can test it WEINRE debugger to see that window opens and then closes with give code.

Regards.


Closing an in app browser during oAuth

Posted: Wed Jul 08, 2015 4:30 am
by Deon

This cant be done. It is browser security.

Scripts cannot close a window if it was not opened by the script.

Simply putting window.close does not work anymore as the Browser Vendors dont allow this anymore due to security reasons.

So in essence app developers are screwed and cannot return to app unless......

the window opened does NOT open a target other than _self and the script that opened the window is still active to close the window, which normally is not the case because you would not normally run a scriptt to open a window just to shut it again.

So I payed with the html component as I have have my app controls wrapped around the inappbrowser. This solution works perfectly, except when the browser session opens another window as _blank. When this happens, the browser breaks out of the app never to return.

As long as the target is _self all is good.


Closing an in app browser during oAuth

Posted: Wed Jul 08, 2015 7:04 am
by Alena Prykhodko

Hello Deon,

That you for clarification.
Can support be of further assistance here?


Closing an in app browser during oAuth

Posted: Wed Jul 08, 2015 3:14 pm
by Deon

Nope. Sadly we can closed this as unresolved.


Closing an in app browser during oAuth

Posted: Tue Oct 13, 2015 6:58 am
by Matthew6678662

Hi Deon,

I see you have tried in the past to do something I need to do - just wondering if you found a way?

I don't want to use the appery.io/view/XX_project_ID__XXX/ method to return from an external webapp, such as facebook auth.

Is there any way to set up my own server-side page that returns to a specific page in the app and closes the browser - and passes the facebook token back to the app?

Using the appery url makes no sense for an app once packaged - especially if not continuing to use appery..

Any help really appreciated..

Thanks!

Matt