Skip to content

[flutter_appauth] add cancellation method for as web authentication session#645

Open
kodejack wants to merge 2 commits into
MaikuB:masterfrom
kodejack:feature/add-cancellation-method-for-ASWebAuthenticationSession
Open

[flutter_appauth] add cancellation method for as web authentication session#645
kodejack wants to merge 2 commits into
MaikuB:masterfrom
kodejack:feature/add-cancellation-method-for-ASWebAuthenticationSession

Conversation

@kodejack
Copy link
Copy Markdown

@kodejack kodejack commented Mar 4, 2026

As this repository hosts two packages, please ensure the PR title starts with the name of the package that it relates to using square brackets (e.g. [flutter_appauth])
#643

@MaikuB
Copy link
Copy Markdown
Owner

MaikuB commented Mar 29, 2026

Thanks for the PR. Can you add some details to your original post on what this PR solves. Currently I'm taking a guess from the API docs for the new method. I would be keen to see if you're able to share info on how to reproduce the problem and/or a recording. Is the example app impacted by the problem this that PR solves? If so, can the example app be updated to show how it makes use of the addition as well?

@vkammerer
Copy link
Copy Markdown

We would be keen to see this PR merged as our application needs it.

Our use case is that we need to close the ASWebAuthenticationSession view from the flutter application before it has completed.

@MaikuB
Copy link
Copy Markdown
Owner

MaikuB commented Apr 26, 2026

@vkammerer any chance you show a video and/or demo code using what this PR provides? I didn't get what you mean by your explanation. My understanding is this is about closing the browser and that's normally handled as part of the redirect so wondering if I'm missing/misunderstanding something

@vkammerer
Copy link
Copy Markdown

@MaikuB our use case is that we want to close the ASWebAuthenticationSession before it redirects normally. To be more precise, the flow is as follows:

  • we open an ASWebAuthenticationSession
  • the user is taken through a web flow that can sometimes finish by tapping an app link / universal link in the browser, or sometimes lead to opening these app links / universal links from third party applications
  • in both cases, the flutter app will handle these links while the ASWebAuthenticationSession is still open
  • then we want to close the ASWebAuthenticationSession and present our Flutter implementation of the flow's completion.

@MaikuB
Copy link
Copy Markdown
Owner

MaikuB commented May 23, 2026

Thanks @vkammerer for the info. At which point does the cancellation method get called and how does it get called? This was one of the reasons I wanted to see if the example app can be updated to show the usage. On that note, does the example app fit the criteria for using the method? So far I can tell the method can close the modal browser by making minor tweaks (e.g. don't await the call that initiates the await request and call the cancellation method after some delay). However, a redirection typically closes the browser so I'm wondering what I'm missing.

Note I'm aware it won't hurt to the method but trying to get more understanding, seeing if it's something suits being in the example app and if there are some examples of usages that I could add through API docs and/or the readme

Edit: is there something that makes this unique to iOS/macOS as well?

Sorry I forgot/missed that @kodejack linked this PR to #643

Copy link
Copy Markdown
Owner

@MaikuB MaikuB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So sorry about confusion @kodejack. The original post still kept the PR message template that is meant to be replaced that I missed you had linked to the issue number underneath it to describe about the problem in more depth. Functionality-wise PR is fine but would you be able to look into the following

  • rename the method. The use of the word "session" refers to ASWebAuthenticationSession but this ends up causing a clash with the notion of a session that refers to a session after a user has logged in. I would recommend something like dismissExternalUserAgent as it's close to the name used within the AppAuth iOS SDK and the notion of an external user agent already exists in this plugin. The documentation would end needing adjustment as a result
  • The API docs for the method within the AppAuth iOS SDK takes a boolean parameter to indicate if the dismissal will be animated or note. Would you be able to expose a similar boolean parameter?

break;
case CANCEL_PENDING_SESSION_METHOD:
// No-op on Android; only iOS/macOS use ASWebAuthenticationSession.
result.success(new HashMap<>());
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a reason to pass an empty HashMap<>()? I believe passing null would suffice

} else if ([CANCEL_PENDING_SESSION_METHOD isEqualToString:call.method]) {
[authorization cancelPendingSessionWithCompletion:^{
self.currentAuthorizationFlow = nil;
result(@{});
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment on Android side, from what I've seen and tried, calling result(nil) would have sufficed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] Expose API to cancel/clear pending ASWebAuthenticationSession on app launch

3 participants