auth0-flutter
auth0-flutter copied to clipboard
Feature/add openurl support
This is a continuation of #393, which seems to have gone stale.
- [x] All new/changed/fixed functionality is covered by tests (or N/A)
- [x] I have added documentation for all new/changed functionality (or N/A)
📋 Changes
- Adds support for the
openUrlparameter in bothloginWithRedirectandlogouton the browser version. -
openUrlrequires auth0-spa-js version2.0.1or 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.0to2.0.1atauth0_flutter/example/web/index.html - Add the snippet below to
loginWithRedirectandlogoutfunctions
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.