Comments (9)
The social provider page is not pushed on top of your app. The browser redirects to the social providers url. That is, from
localhost:3000
tomyaccounts.google.com
(for Google sign in). At that point your app is no longer active. Once authentication is complete the browser will redirect back to your application. It is correct that any code afterawait Amplify.Auth.signInWithWebUI()
will not execute in this case.after I sign In and the redirect comes back to my app, my app has not received a token
I could not reproduce this. I am redirected back to
http://localhost:3000/?code=<code>&state=<state>
and have an active authentication session.Are you seeing any errors? How do you know that there is not a successful sign in?
Hi, Thanks for your reply @Jordan-Nelson. Apologies, this issue was not with AWS amplify library. This issues is resolved. I had to restructure a bit my own app. I basically start using await awsSessionRepo.getCurrentUser() to detect user sign status in my main() and it worked. And also i did below in vs code.
Go to settings
Search for Dart: Flutter Run Additional Args
Enter --web-port=3000
Click Add Item
Hence, no more issues apart from "breakpoints" stopping execution when running app with "start Debugging" mode, for which i can for now use "Run without debugging" where I can receive exception in try catch. And once the SDK is fixed, will check again. Thanks for your help.
from amplify-flutter.
Hello - thanks for opening the issue. We will see if we can reproduce this with the info provided.
from amplify-flutter.
Hello - I attempted to reproduce the issue you are experiencing on Android and iOS and cannot reproduce it. I do see the break point hit. I have a few follow up questions:
- What IDE are you using?
- How are you launching/running the flutter app
- Can you confirm you are running in debug mode and have break points enabled?
from amplify-flutter.
Hello - I attempted to reproduce the issue you are experiencing on Android and iOS and cannot reproduce it. I do see the break point hit. I have a few follow up questions:
- What IDE are you using?
- How are you launching/running the flutter app
- Can you confirm you are running in debug mode and have break points enabled?
Hi, Thanks for reply. I am using vscode. I have also tested after running "Removed All BreakPoints" in vscode.
I see the exception when i run with "Start Debugging" and the exception is received in my try catch block when I use "Run without debugging", my try catch block receives exception (as expected).
Also, I don't see any issues with any other exceptions when using "Start Debugging". These breakponts stops execution ONLY with the code I copied below. Is this expected behaviour & can this be changed?
Below is more info on this issue for each platform but with "Start Debugging" & "Run without debugging".
1. ANDROID. UrlLauncherException (No browser installed in emulator)
a. "Run without debugging". Execution dont stop with exception.
I see exception as expected in try catch and execution is not stopped.
b. "Start debugging". Execution stops with exception.
Execution stops as in image below. Note, I already have queries populated in AndroidManifest.xml.
"Start Debugging" causes exception to stop the execution as below. If I run with "Run Without Debugging", it works as excpected for android and iOS. For MacOS & Chrome there are still issued as sumarized below.
2. iOS. UserCancelledException (Browser installed in emulator).
Open and close a sign in browser in iOS.
a. "Run without debugging". Execution dont stop with exception.
I see exception as expected in try catch and execution is not stopped.
b. "Start debugging". Execution stops with exception.
Execution stops as seen in image below.
3. MacOS. UserCancelledException (Browser installed)
a. "Run without debugging". Execution dont stop with exception.
If a browser is opened a and then closed without sign in completed. I see no UserCancelledException first time when browser is closed. It shows up second time a browser is opened for another sign in attempt. And then if you open browser again, no exception, but when you close and open again, you see below exception. I.e. the exception UserCancelledException occurs when browser is opened second time and onwards (instead when it is closed).
The user cancelled the sign-in flow
b. "Start debugging". Execution dont stop with exception.
Exact same behaviour as above i.e. If a browser is opened a and then closed without sign in completed. I see no UserCancelledException first time when browser is closed.
NOTE: For macos program execution did not stop at UserCancelledException neither with "Start debugging" nor with "Run without debugging".
4. Chrome. Separate issue where hosted ui pushed on top of app instead of a separate tab.
-
When Sign in is clicked, instead of a new page opening on a new tab for sign In, a new page is pushed instead. Is there a way to have new tab open for sign in separate to the app window so app window and sign in window can be handled separately. This is because, I cannot control back button behaviour of amplify hosted_ui and hence a separate window will ensure that if I colse or refresh etc amplify hosted_ui, i can see exceptions in my app ui window in separate chrome tab.
-
I have setup :myapp// and http://localhost:3000/ to test Sign In On Web. I run web app as below:-
flutter run -d chrome --web-port 3000
After that, when i try social sign in, with function below, I hit the line "Commence sign in" below but no other output. My app just restarts from home page back to login. This happens even if I get asked to add auth credentials on by social sign in. After that I just don't see any output from below function. And to me reason for this is might be because of the point 1) above i.e. hosted_ui is pushed on top of my home route and then when the process finishes, my app restarts from home route. I could check this if hosted_ui is created in separate tab.
debugPrint('Commence sign in ... ');
final SignInResult signInResult = await Amplify.Auth.signInWithWebUI(
provider: _getAuthProvider(signInOption),
);
REFERENCE CODE:
on Exception catch (e) {
switch (e) {
case PlatformException(code: 'CANCELLED'):
throw const UserCancelledException(
'The user cancelled the sign-in flow',
);
case PlatformException(:final code, :var message):
// Generated Android message is `CLASS_NAME: message`
if (message != null && message.contains(': ')) {
message = message.split(': ')[1];
}
String? recoverySuggestion;
if (code == 'NOBROWSER') {
recoverySuggestion =
"Ensure you've added the <queries> tag to your "
'AndroidManifest.xml as outlined in the docs';
}
throw UrlLauncherException(
message ?? 'An unknown error occurred',
recoverySuggestion: recoverySuggestion,
);
default:
rethrow;
}
}
from amplify-flutter.
@dkliss - Thanks for the detailed info. I think I had misunderstood the issue originally.
When I run an app in debug mode with "Uncaught Exceptions" enabled in VS code and follow the repro steps I do see the debugger stop in /hosted_ui_platform_flutter.dart
as you have noted. I can reproduce this with flutter version 3.16, but not flutter version 3.13. I think this is related to #4345 and flutter/flutter#141882 but I need to investigate a bit more.
Repro steps I am using:
- Run app with social sign in enabled (I am using iOS, but probably can be reproduced with Android)
- Launch social sign in
- Cancel social sign in
- Observe that the debugger pauses in
/hosted_ui_platform_flutter.dart
which is not expected.
from amplify-flutter.
I am going to label this as a bug for now, although at the moment I am unsure if this is a bug in Amplify Flutter or the Flutter/Dart SDK.
from amplify-flutter.
@dkliss - I am fairly certain this is caused by flutter/flutter#141882, which has been resolved in flutter master. I can reproduce this with Flutter v3.16, but cannot reproduce this with flutter master. Note, I also cannot reproduce this with flutter 3.13 (which is consistent with flutter/flutter#141882).
I will leave this open until the Dart SDK fix gets cherry picked to a stable version of dart in case others are running into this issue. For now if you switch to flutter master you should not see the debugger pause in /hosted_ui_platform_flutter.dart
.
from amplify-flutter.
@dkliss - I am fairly certain this is caused by flutter/flutter#141882, which has been resolved in flutter master. I can reproduce this with Flutter v3.16, but cannot reproduce this with flutter master. Note, I also cannot reproduce this with flutter 3.13 (which is consistent with flutter/flutter#141882).
I will leave this open until the Dart SDK fix gets cherry picked to a stable version of dart in case others are running into this issue. For now if you switch to flutter master you should not see the debugger pause in
/hosted_ui_platform_flutter.dart
.
Thanks @Jordan-Nelson I will wait for flutter SKD fix for this.
Any comments in Point 4 I mentioned above on Chrome. Below is what is happening.
- I run app in chrome using below.
flutter run -d chrome --web-port 3000
App opens on localhost:3000.
- I click sign in with social provider. Social provider page is pushed on top of my app (instead of opening a separate page as seen in mobile and desktop apps). I see following function is called
debugPrint('Commence sign in ... ');
final SignInResult signInResult = await Amplify.Auth.signInWithWebUI(
provider: _getAuthProvider(signInOption),
);
- But the after 'Commence sign in ...' , my app below the hosted_ui app does not show execution of await Amplify.Auth.signInWithWebUI function. I.e. after I sign In and the redirect comes back to my app, my app has not received a token.
Might reproduce by below:
- Run app on chrme (not the hosted_ui) but actual app with web app with own sign in buttons.
- Click sign in button on app, which will then push hosted_ui page on it.
- After sign in, when the app redirect back, to my OWN sign In page, I see no token received and no auth approved (i.e. Amplify.Auth.signInWithWebUI is not run as part of my web app). The same logic works on MACoS, iOS and Android.
from amplify-flutter.
The social provider page is not pushed on top of your app. The browser redirects to the social providers url. That is, from localhost:3000
to myaccounts.google.com
(for Google sign in). At that point your app is no longer active. Once authentication is complete the browser will redirect back to your application. It is correct that any code after await Amplify.Auth.signInWithWebUI()
will not execute in this case.
after I sign In and the redirect comes back to my app, my app has not received a token
I could not reproduce this. I am redirected back to http://localhost:3000/?code=<code>&state=<state>
and have an active authentication session.
Are you seeing any errors? How do you know that there is not a successful sign in?
from amplify-flutter.
Related Issues (20)
- Large Integers Parsed as Double with Scientific Notation HOT 3
- Didn't get any event from listener Amplify HubChannel Datastore after first time login user account
- Silo Multi-tenant Flutter app using AWS Amplify with one frontend HOT 5
- Debugger pauses in `aws_retryer.dart` when using Flutter 3.16 HOT 10
- Feature Request: GraphQL API request need copyWith method HOT 6
- [Authenticator] There is no way to customize alerts for exceptions and their messages HOT 1
- GraphQL create request error. HOT 70
- GraphQL AppSync Subscription Sync error "GraphQLResponse.Error{message='Cannot return null for non-nullable" HOT 3
- AWS lambda function error HOT 3
- No auth provider found for auth mode function HOT 8
- java.io.FileNotFoundException: can't read keyset while initializing Amplify HOT 6
- [Feature Request]: Custom Http headers in Amplify Auth HOT 1
- AWSSigV4Signer fails authentication with AWS IOT using MQTT over WSS HOT 1
- [Bug] LoadingScreen should have CircularProgressIndicator.adaptive() HOT 2
- [Documentation] Flutter example in amplify gen 2 documentation missing binding init HOT 6
- Issues with Model Generation via Amplify Codegen in Flutter HOT 6
- [Feature request] Remember device does not allow specify name HOT 4
- Can not set a nullable string index to null HOT 13
- Token refresh does not work when USER_PASSWORD_AUTH is used with Device Tracking HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-flutter.