FormidableLabs / react-native-app-auth

React native bridge for AppAuth - an SDK for communicating with OAuth2 providers
https://commerce.nearform.com/open-source/react-native-app-auth
MIT License
2.03k stars 440 forks source link

Dismiss authorize() webview and return focus to the App programatically #830

Open gom1 opened 1 year ago

gom1 commented 1 year ago

Is there a way to programatically dismiss the webview that pops up when calling authorize()? There is a 'Cancel' button to close the authorize() webview but is there a way to do this programatically?

bsumer-wyn commented 1 year ago

Is there a way to programatically dismiss the webview that pops up when calling authorize()? There is a 'Cancel' button to close the authorize() webview but is there a way to do this programatically?

This is exactly what I am looking for too. On android when you take the app in background while this webview is open, it throws and error and closes it, I'd like to programmatically close this on android if the app is taken to the background if authorize() function is called.

vishrut commented 1 year ago

+1.

This would be very useful for auth flows where the expected outcome is not a successful authorization but something akin to a reset-password flow (where an email is sent to your inbox and the auth webpage is no longer relevant).

srithar21 commented 7 months ago

In iOS also, looking for this solution for dismissing the page programmatically. Any solution?

doneitas commented 7 months ago

In iOS also, looking for this solution for dismissing the page programmatically. Any solution?

I needed this functionality as well, so just added close method locally with patch-package

srithar21 commented 7 months ago

@doneitas can you please share the details of above fix details and patch-package?

doneitas commented 7 months ago

@doneitas can you please share the details of above fix details and patch-package?

Sure. These are the changes:

RNAppAuth.m - https://www.diffchecker.com/Nyb1Kt0g/ index.d.ts - https://www.diffchecker.com/LZRRnSGA/ index.js - https://www.diffchecker.com/QqZ6Vsnv/

I don't think this solution is perfect but it does the job. It basically exposes new close method which can be called to cancel existing session programmatically (iOS only)

Brittognanaraj commented 6 months ago

@doneitas Is that any solution for android to dismiss the page programmatically

doneitas commented 6 months ago

@doneitas Is that any solution for android to dismiss the page programmatically

Unfortunately, I don't have such a solution. I only needed iOS for my particular case