Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose signinCallback for native applications #1330

Closed
wants to merge 5 commits into from
Closed

Conversation

tmo207
Copy link

@tmo207 tmo207 commented Aug 8, 2024

Closes/fixes #1216 #1145

Capacitor apps do not trigger signinCallback when returning from the browser to the app. By calling signinCallback manually the user is able to finish authenticaion.

Example:

CapApp.addListener("appUrlOpen", async ({ url }) => {
    // TODO: handle URL
    ...
    await auth.callSigninCallback('/some-path' + authParams);
   ...
});

The problem here is that the AuthState is not updated after the call. The reducer is called with the correct values (isLoading: false, isAuthenticated: true), but the native app needs a manual reload to update the AuthState. Any idea why this might be @pamapa ?

Checklist

  • This PR makes changes to the public API
  • I have included links for closing relevant issue numbers

@tmo207 tmo207 marked this pull request as draft August 8, 2024 21:09
@tmo207 tmo207 marked this pull request as ready for review August 11, 2024 09:30
@pamapa
Copy link
Member

pamapa commented Aug 20, 2024

The problem here is that the AuthState is not updated after the call. The reducer is called with the correct values (isLoading: false, isAuthenticated: true), but the native app needs a manual reload to update the AuthState. Any idea why this might be?

This MR is more a workaround than a fix and is missing } catch (error) {... and surrounding useCallback(.

The reducer creates a new state, which should be propagated via useReducer, respectively via useAuth into the application. Assuming that within the application the state is not cached (useMemo) i would assume that code element would be re-rendered...

@taszilvo
Copy link

Hey guys @tmo207 @pamapa! I am still curious about the potential fix for the issue with capacitor apps. What happened with this PR? Could you somehow solve the bug at the end?

@pamapa
Copy link
Member

pamapa commented Sep 20, 2024

@taszilvo if you really need it, there is no other way we can add something like this. The name of the new exposed function would be signinCallback. On the other hand if you create the UserManager object outside and pass it into AuthProvider, you can do whatever you like on that object...

@tmo207
Copy link
Author

tmo207 commented Dec 16, 2024

You're right, passing the UserManager from outside and calling signInCallback on it works. Thanks for the help!

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.

Possibility to access signinCallback function?
3 participants