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

Feature/add openUrl support #393

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

JCQuintas
Copy link

@JCQuintas JCQuintas commented Dec 22, 2023

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

  • Adds support for the openUrl parameter in both loginWithRedirect and logout on the browser version.
  • openUrl requires auth0-spa-js version 2.0.1 or later.
  • It makes the lib more closely aligned with the auth0-spa-js lib which is used underneath.

This is important to me due to the @microsoft/teams-js library necessary to do authentication inside microsoft teams, reference docs here

In short, it handles authentication in its own window.

authentication.authenticate({
    url: window.location.origin + "/tab-auth/simple-start-v2",
    width: 600,
    height: 535})

My use case would be something similar to

auth0.loginWithRedirect(openUrl: (auth0Url) async {
  authentication.authenticate(
    url: "$auth0Url/tab-auth/simple-start-v2",
    width: 600,
    height: 535
  )
})

🎯 Testing

  • In order to test, replace the auth0-spa-js version from 2.0 to 2.0.1 at auth0_flutter/example/web/index.html
  • Add the snippet below to loginWithRedirect and logout functions
openUrl: (final url) async {
  debugPrint(url);
  window.location.replace(url);
}
  • Ensure you will see the urls printed on the console.

Possible concerns

While manual testing, you will also see two errors in the web console:

  • Error: Promise was rejected with a value of 'undefined'
  • TypeError: T.as is not a function

From my tests, this seems be comming out of the main auth0-spa-js library due to unhandled rejections, and doesn't affect the usage of auth0_flutter itself. Though it would require a deeper research on why it is happening.

@JCQuintas JCQuintas requested a review from a team as a code owner December 22, 2023 12:41
@JCQuintas
Copy link
Author

@Widcket @poovamraj Hi, please let me know if I am missing any step for this to be reviewed 😄

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.

1 participant