auth0 / auth0-flutter

Auth0 SDK for Flutter
https://pub.dev/documentation/auth0_flutter/latest/
Apache License 2.0
57 stars 36 forks source link

redirect_uri incorrect in `auth0.onLoad()`. #409

Open jwalton opened 4 months ago

jwalton commented 4 months ago

Checklist

Description

When I login with:

_auth0 = Auth0Web(domain, clientId);
_auth0.loginWithRedirect(
  redirectUrl: 'http://localhost:8080/callback",
);

_auth0.onLoad().then((final credentials) { ... }

This works as expected. But, if I reload the page, the onLoad() attempts to do a "silent authentication" to recover my credentials and this fails. The onLoad() results in a network request being sent that looks like:

https://xxxx.auth0.com/authorize?...&redirect_uri=https%3A%2F%2Flocalhost%3A8080&...

And this fails, with the logs reporting "Failed Silent Auth: Callback URL mismatch. https://localhost:8080 is not in the list of allowed callback URLs."

This is correct: that URL is not in my list of allowed callback URLs, and nor do I want it to be. But, onLoad() doesn't seem to accept a redirectUrl as a parameter.

You can work around this with:

_auth0.onLoad(parameters: {'redirect_uri': _redirectUrl}).then((final credentials) {...})

But, yuck. It would be much nicer if the Auth0Web constructor accepted an optional redirectUri parameter like the js version does.

Reproduction

n/a

Additional context

No response

auth0_flutter version

1.5.0

Flutter version

3.20.0-7.0.pre.17

Platform

Web

Platform version(s)

No response