Closing an in app browser during oAuth

This forum contains topics that were moved from Get Satisfaction
DaveVockell
Posts: 0
Joined: Thu Dec 12, 2013 10:26 am

Closing an in app browser during oAuth

Post 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?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Closing an in app browser during oAuth

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

DaveVockell
Posts: 0
Joined: Thu Dec 12, 2013 10:26 am

Closing an in app browser during oAuth

Post 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?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Closing an in app browser during oAuth

Post by Alena Prykhodko »

Hello,

Please provide detailed app workflow in steps.

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Closing an in app browser during oAuth

Post 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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Closing an in app browser during oAuth

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

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Closing an in app browser during oAuth

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Closing an in app browser during oAuth

Post by Alena Prykhodko »

Hello Deon,

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

Deon
Posts: 0
Joined: Sun Jun 30, 2013 6:00 am

Closing an in app browser during oAuth

Post by Deon »

Nope. Sadly we can closed this as unresolved.

Matthew6678662
Posts: 0
Joined: Tue Oct 13, 2015 6:58 am

Closing an in app browser during oAuth

Post 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

Post Reply