flutter_web_auth
flutter_web_auth copied to clipboard
Flutter web authenticate method loop forever
After calling the FlutterWebAuth.authenticate method and the page auth.html is shown, the method never returns, it loops forever. I am using flutter web. I am trying to get the ebay user authorization code. This is the code: ```
Map<String, dynamic> queryParams = {
"client_id": ebayAuthSnapshot['EBAY_CLIENT_ID'],
"response_type": "code",
"redirect_uri": ebayAuthSnapshot['EBAY_REDIRECT_URI'],
"scope":
"https://api.ebay.com/oauth/api_scope https://api.ebay.com/oauth/api_scope/buy.order.readonly
};
// Construct the url
final url = Uri.https(base, path, queryParams);
// Present the dialog to the user
final result = await FlutterWebAuth.authenticate(
url: url.toString(), callbackUrlScheme: "/auth.html");
print(result); // never print
auth.html file:
<!DOCTYPE html>
<title>Authentication complete</title>
<p>Authentication is complete. If this does not happen automatically, please
close the window.
<script>
window.opener.postMessage({
'flutter-web-auth': window.location.href
}, window.location.origin);
localStorage.setItem('url', window.location.href);
window.close();
</script>
The redirect url after a succesful grants was set on the ebay developers account. What is wrong?
Can you debug if window.opener.postMessage
in auth.hmtl is called? Or in your case the URL is stored to local storage?
There is no window.opener.postMessage message called.
Please read the trouble shooting section at the bottom of the readme.md in
https://github.com/harrowmykel/flutter_web_auth#troubleshooting
There is no window.opener.postMessage message called.
Your page must call window.opener.postMessage
in order to signal that the authentication is complete.
Is the user redirected to the auth.html
page at all?
Please also take a look at the troubleshooting and see if that helps you, if not we can reopen
https://github.com/LinusU/flutter_web_auth#troubleshooting