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

[RFC]: Amplify Flutter #5

Closed
Amplifiyer opened this issue Jul 21, 2020 · 73 comments
Closed

[RFC]: Amplify Flutter #5

Amplifiyer opened this issue Jul 21, 2020 · 73 comments
Labels
feature-request A request for a new feature or an enhancement to an existing API or category.

Comments

@Amplifiyer
Copy link
Contributor

Amplifiyer commented Jul 21, 2020

This issue is a Request For Comments (RFC). It is intended to elicit community feedback regarding support for Amplify library in Flutter platform. Please feel free to post comments or questions here.

Purpose

Currently there is no official support for integrating with Amplify libraries in Flutter apps. This RFC goes over a proposal to build and release Amplify libraries in pub.dev that can be used in cross platform flutter apps.

Goals

  • Amplify iOS and Amplify Android parity: We would like to support all the use cases supported by these platforms in Amplify Flutter, including the following categories
    • Analytics
    • API (Rest/GraphQL)
    • Authentication (including Hosted UI)
    • DataStore
    • Predictions
    • Storage
    • Hub Events (Listening to the Amplify events)
  • Consistency with other platforms: Keep the public interface and API behavior consistent with Amplify iOS and Android libraries.
  • Pluggability: Customers should be able to implement/add their own cloud provider plugins for a given category.
  • UI Components: Provide a set of UI components intended to help developers leverage Amplify categories such as API, Auth, Storage etc.

Definitions

Categories: Use case driven abstractions such as Auth, Analytics, Storage that provide easy to use interfaces.
Providers: A cloud provider or a service provider such as Cognito, Auth0 in Auth category; Kinesis, Pinpoint and Firehose in Analytics Category; Rekognition, Textract in Predictions Category.
Plugins: Also called Amplify Plugins, bind providers to categories. They implement provider functionalities adhering to categories easy-to-use interfaces. Amplify Plugins already exist in native platforms (iOS/Android), this RFC explores creation of similar plugins in Flutter.
Flutter Plugins/Platform Plugins/Federated Plugins: These are native platform code and modules that is called from flutter apps or libraries over a method channel.

Proposed Solution

High Level Overview

Amplify flutter will be architected as a pluggable interface across all the categories listed in the Goals. The pluggable interface will allow plugging in different cloud providers (e.g. Auth0 or Cognito for Auth category) which can be written either entirely in Dart or using Flutter's Platform Plugins to reuse native (iOS and/or android) modules.

The core of Amplify Flutter will be written in Dart which provides the pluggable interface and out of the box AWS cloud provider plugins will utilize existing Amplify Android and Amplify iOS libraries as Flutter's federated plugins. This means that we will not be implementing a Dart aws-sdk right away as AWS service calls will be made by Amplify Android/iOS libraries.

The Amplify flutter library will be compatible with Amplify CLI to create and provision your cloud providers' resources. Amplify CLI will generate a configuration file to easily configure your Flutter app to use these resources.

Pros

  1. We can reuse most of the existing Amplify native libraries' AWS providers and ship to customers faster.
  2. Some initial bench-marking proves that executing native platform code is generally faster than dart code.
  3. New features introduced in native libraries can be made available in Flutter with very minimal to no change.
  4. Provides flexibility to write providers' (AWS or others) implementation entirely in Dart if needed in the future.

Amplify Flutter(2)

Developer Experience

  • Creating and provisioning resources will remain the same with amplify CLI https://docs.amplify.aws/cli/start/workflows
  • Integrating with Amplify Flutter
    • Flutter Apps will import AmplifyCore and the plugins they want to use in the app.
    • In the app, developers will be required to call Amplify.addPlugin() for each plugin they import e.g. Amplify.addPlugin(CognitoAuthPlugin())
    • Developers will call Amplify.Category.<API> to use installed plugins, e.g. Amplify.Auth.signIn()
  • Developing and debugging Amplify Flutter
    • Refer official flutter guide to learn how to debug provider plugins that are written entirely in Dart and the ones that use platform federated plugins.
  • Using Amplify UI components for Flutter - Coming Soon

FAQs

Q. Which versions of Android and iOS are supported?
Same versions as supported by Amplify Android and Amplify iOS libraries.

Q. How will escape hatches work with Amplify plugins that use native libraries?
Coming Soon.

Q. How will events that are emitted in native libraries reach Flutter apps.
We will use Flutter's event channels to subscribe events on the native platform and transmit them over to Dart end.

Q. Will web and Desktop platform be supported?
Not right away, our goal with this design is to keep the architecture flexible such that more platforms can be supported in the future.

Q. Can I migrate my Amplify CLI generated config from Android, iOS or JS platform to flutter?
Not right now. We will look into the feasibility of supporting this in the future.

@mlabieniec mlabieniec pinned this issue Jul 24, 2020
@andyfurniss4
Copy link

Glad to hear that Amplify support is coming.

Can I please request that this supports custom authentication flows?

The current Amplify documentation pages for Android and iOS suggest initiating auth with username and dummy password and then changing the Cognito Define Auth Challenge to override the SRP_A challenge with a custom challenge. This effectively means you can't have both flows for a single Cognito user pool.

We have two applications which use the same user pool but have different sign in methods - one is custom and one is SRP_A. I am unable to use Amplify because I'm forced to do this hacky override in the Cognito trigger so we've resorted to using the Cognito SDK (non-amplify) directly.

I believe custom flow may already be implemented in the JavaScript library because the password parameter is optional on the signIn function: https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#signin but this is not the case for Android or iOS so I'm not sure if this is in scope for this project or not. I can raise this as an issue in the Android and iOS repos too if necessary.

@haverchuck
Copy link
Member

Can I please request that this supports custom authentication flows?

@andyfurniss4 Thanks for your feedback - we will definetely investigate this feature request!

@hpoul
Copy link

hpoul commented Aug 20, 2020

Are there any plans to actually implement the client libraries in native dart code? Would be nice not to rely on platform messages to just bridge everything to the android/iOS libraries, this would make it work on all platforms (ie. also on desktop platforms macos, windows, linux). It gets really great when you can use the same code for mobile and desktop ;-)

@vmadupu9
Copy link

In future can we expect Amazon SNS wrapper as part this package ? This will give us the ecosystem of various AWS features in single package.

@e-dedecube
Copy link

At the moment there is no federate sign in methods. Did I missed something or is actually still to be implemented?

@joekendal
Copy link

Honestly, we are not that bothered with auth as it is something easy to do without AWS. What we want to have is DataStore sync like Google Firestore.

@devorso
Copy link

devorso commented Aug 22, 2020

I'm looking forward to the feature Datastore..

@haverchuck
Copy link
Member

@dedecube OAuth authentication is definitely on the roadmap!

@devcshort
Copy link

DataStore and API would be great to have

@m11gt
Copy link

m11gt commented Sep 12, 2020

DataStore and API (Rest and GraphQL) asap please. I am in love with flutter and want to use AWS as my backend for the project I am designing. I don't want to give in and use firebase. Any idea what the timeline will look like. Even preview will work!

@dariotrombello
Copy link

Agree. Can't wait to switch from firebase to amplify.

@rlee1990
Copy link

DataStore and API (Rest and GraphQL) are definitely a big need. Is there a time table for when we can see these added?

@guoguoguilai
Copy link

We need AppSync!

@joekendal
Copy link

As you can see, we're all pretty desperate for DataStore. If we could do anything to help I would gladly open pull requests but is there a list of things TODO ? 🥴

@Amplifiyer
Copy link
Contributor Author

Hi all, we are currently working on the design for the datastore and will put it here or in another RFC to gather feedback. Please stay tuned.

@kjones
Copy link

kjones commented Sep 17, 2020

Hi all, we are currently working on the design for the datastore and will put it here or in another RFC to gather feedback. Please stay tuned.

Edit (2021-02-16): Flutter SDK now supports DataStore so no need for the following hack.

If you are impatient like I am 😏, or your product release schedule can't be adapted to wait for DataStore support in this library, then you can write your own Flutter DataStore platform plugin that lives alongside this library.

I've created an example Flutter plugin and app to demonstrate a way to do this. That code can be found here: https://github.com/kjones/flutter-datastore-example

This is not a generic solution that will work with any GraphQL schema. It has to be targeted specifically to match your schema. Dart model classes have to be hand rolled since the Amplify codgen tools don't yet support Dart.

While this solution is far from perfect, it should give you a head start on using DataStore in your Flutter app while we wait for official support.

@matthickey709
Copy link

Is there a timeline for supporting Flutter Web with AWS? I can get it working great on the iOS simulator but it can't configure amplify when running on web. Would be great to have the web app running too!

@nautsimon
Copy link

hate to ask a question like this, but I am wondering about the timeline for "production-grade" authentication. Currently, I am working on a big project with about a year-long timeline. Our stack is built primarily with flutter and aws services and we have tested "hello world" auth via amplify and it works great. However, because these features are labeled as "previews" and explicitly recommended not to be used in production, I was wondering when there would be reasonable certainty in the viability of flutter auth with amplify. Thank you!

@joekendal
Copy link

@simonmahns I hear if you email your concerns to jeff@amazon.com enough times he forwards it to the right person to resolve 😅

@rlee1990
Copy link

rlee1990 commented Oct 6, 2020

Is there a weekly or bi-weekly progress report so we can know what to expect?

@jamesdixon
Copy link

@Amplifiyer thanks for the update on DataStore. If there's any update, would love to hear it. Also, more than happy to help alpha test anything :)

@Amplifiyer
Copy link
Contributor Author

@jamesdixon, we had been designing the datastore category for flutter and starting the implementation now. Stay Tuned!. I'll be putting up an RFC soon on this repo for visibility.

@joekendal
Copy link

@sbutlerjr
Copy link

+1 desperate for DataStore.

@DanielChuDC
Copy link

DanielChuDC commented Jan 22, 2021

Any plan on adding push notification support like the firebase does with firebase_messaging that would integrate with SNS?

@jobypthomas This is definitely something we are planning to add to our roadmap for this year. Please go ahead and open up a feature request with what you would like to see supported for notifications. This would help other customers upvote/contribute as well.

Hi if nobody created this feature request, I will create a feature request on the push notification support describe according to @jobypthomas. I am working on a project using amplify and required push notification. Looking forward to see how amplify can enable this feature.

@rlee1990
Copy link

@Amplifiyer any timeline on support for GraphQL APIs?

@kjones
Copy link

kjones commented Jan 27, 2021

any timeline on support for GraphQL APIs?

It has been there since 0.0.1-dev.6 I think?
https://docs.amplify.aws/lib/graphqlapi/getting-started/q/platform/flutter

@rlee1990
Copy link

Did not see that thanks

@Amplifiyer
Copy link
Contributor Author

@rlee1990 Graphql query and mutations are currently supported in the latest versions. Subscribe API will be available in our next versions.

@joekendal
Copy link

@Amplifiyer thanks for updating us on the subscriptions API, will this be a Dart implementation or calling the iOS and Android libraries? If so then I think we can use this for Desktop I would think.

@Amplifiyer
Copy link
Contributor Author

@joekendal, this will be a wrapper over iOS and Android libraries.

@PawlikMichal25
Copy link

@Amplifiyer
Can you give us update about when Third-Party Sign-Ups (Google, Apple, Facebook) are gonna be implemented?
At least more or less estimation :)

@Amplifiyer
Copy link
Contributor Author

Amplifiyer commented Jan 27, 2021

@BaranMichal25, we recently released 0.0.2-dev.1 version which has this feature (Hosted UI or Social SignIn). More details here https://docs.amplify.aws/lib/auth/signin_web_ui/q/platform/flutter

@PawlikMichal25
Copy link

@Amplifiyer
woah, that's great news, thanks! :)

Can you give me an estimate when Apple Sign In will be supported as well?

@Amplifiyer
Copy link
Contributor Author

Amplifiyer commented Jan 27, 2021

@BaranMichal25, we haven't tested Apple SignIn yet, it should work though when you follow the steps here. Couple of points to note are

  1. Apple SignIn is currently not supported to be provisioned (or setup) through amplify cli as mentioned in the above link.
  2. You won't be able to launch the Apple Sign In page directly using the provider input. When you call Amplify.Auth.signInWithWebUI();, all the third party providers configured with Cognito will be available for sign in (including Apple). Once we complete the testing, we will add this provider so you can launch Apple sign in directly (bypassing the Cognito's hosted UI)

@PawlikMichal25
Copy link

@Amplifiyer
Thanks, I followed the steps you mentioned and it mostly worked, which is great.

I just have one issue currently:

  1. I call the Amplify.Auth.signInWithWebUI();
  2. A general sign up page is displayed with all 3 party providers I'm using
  3. I choose Apple, authorise, looks like everything is successful, but:
    I end up on a blank page and nothing happens.
  4. If I click cancel on the browser and then call Amplify.Auth.signInWithWebUI(); again, then I'm automatically correctly authorised and navigated back.

So it looks like authentication worked, but just something is wrong with redirects or some callbacks?
Do you have any ideas or suggestions about what might be going wrong?

@Amplifiyer
Copy link
Contributor Author

Thanks @BaranMichal25 for trying this out and letting us know the issue and reproduction steps. We will try to reproduce this on our end. It will help if you can open a new issue with the same details to help us track better.

@Amplifiyer Amplifiyer added the feature-request A request for a new feature or an enhancement to an existing API or category. label Feb 6, 2021
@pierceglennie
Copy link

Hi @Amplifiyer. Is custom auth supported by this library yet? Specifically, I'm using a magic link set up with Amplify on the web (which works well) and I'm trying to support it on iOS and Android with Flutter. It doesn't seem to be working but I'm not sure if that's because the library just doesn't support it yet or if I'm doing something wrong.

If it's not supported, do you have any idea when it might be added? It's a critical feature for me – if it's not imminent then I'll have to look into alternative options.

If it is supported, I'll raise a separate issue to see what's going on. In brief, I've have the app working with username and password login but when I change to "authenticationFlowType": "CUSTOM_AUTH" in amplifyconfiguration.dart and try to sign in I get an AMPLIFY_SIGNIN_FAILED error each time. I would expect to get a response with the next step being submitting the confirmation code from the magic link.

@Amplifiyer
Copy link
Contributor Author

Amplify-flutter is now GA with new stable release 0.1.0
https://aws.amazon.com/blogs/aws/amplify-flutter-is-now-generally-available-build-beautiful-cross-platform-apps/

@kjones
Copy link

kjones commented Feb 16, 2021

@Amplifiyer and the entire team. Congratulations and thanks for all of the hard work!

@haverchuck
Copy link
Member

@pierceglennie When you say "magic link set up with Amplify" you mean the email link set up with Amplify CLI? If so, how exactly are you doing the routing in flutter?

To answer your question - We are working on finalizing the custom auth capabilities of amplify-flutter, so please stay tuned.

@pierceglennie
Copy link

Sorry, I should have been clearer. The log in process on our website is:

  • User enters their email and requests a log in link. The link contains a one time log in code as a query parameter

  • When they click the link, we take them to a log in page which authenticates them using Amplify. Basically we call sign in with just the username (no password) and then respond to the custom auth challenge with the code from the email link. On the Cognito side, the verification of the code uses some custom lambda scripts

  • We also give people the option to log in with a password if they prefer and have one set up

The process is pretty much as described here, except we pass the code via the query string of the login link rather than requiring the customer to type it in: https://aws.amazon.com/blogs/mobile/implementing-passwordless-email-authentication-with-amazon-cognito/

For our Flutter app, we are looking to implement the same process for consistency (and since many customers don't have passwords). We have username and password log in working fine but it's the log in link process we're having issues with.

We can successfully request a log in link (this happens via our own API which sets the custom auth code on Cognito). We have also set up this link so it will open our app using universal links. Once it's opened our app, we can extract the code from the query string.

The only bit that we're struggling on is that the sign in method of the Amplify Flutter library requires the password (unlike the javascript library) which we don't have. On the iOS library, the docs recommend passing a dummy password to support this flow and then you'll get an Auth challenge as a response (and then you send the code). This doesn't seem to work with the Flutter library though, we just get a failure response.

We have tried changing the authentication method to "CUSTOM_AUTH" in the amplify configuration file by the way. However, this doesn't fix the issue (probably because it's not yet supported) and it also stops username/password log in from working.

Thanks for the great work on the library so far by the way!

@praharshbhatt
Copy link

The only bit that we're struggling on is that the sign in method of the Amplify Flutter library requires the password (unlike the javascript library) which we don't have. On the iOS library, the docs recommend passing a dummy password to support this flow and then you'll get an Auth challenge as a response (and then you send the code). This doesn't seem to work with the Flutter library though, we just get a failure response.

Any resolution on this?
We are looking to have a passwordless auth as well, and running into the same issues as you are...

@pierceglennie
Copy link

I didn't find any resolution. I'm basically waiting in the hope that it gets added to the library at some point relatively soon.

@praharshbhatt
Copy link

I didn't find any resolution. I'm basically waiting in the hope that it gets added to the library at some point relatively soon.

I was able to do this, check out my answer here: https://stackoverflow.com/a/66463088/6559381

@pierceglennie
Copy link

Thanks, that's good to see. I might try that out if it's not added to the official library in the next couple of months (it's not holding us back right now)

@Amplifiyer Amplifiyer unpinned this issue Mar 17, 2021
@ShourryaGuha
Copy link

How to add Amplify endpoint to flutter app for the .apk release of the app?

I have been trying to make the .apk release of my flutter login app (which uses amplify as the backend) work but it gives out an error. The app works when I run it on an emulator or when my phone is connected to my laptop in developer mode. I have no clue where the endpoint needs to be set for the .apk release. Please help?
Below is the screenshot of the error popping up.
https://i.stack.imgur.com/DvFKo.jpg

@Amplifiyer
Copy link
Contributor Author

@shouza1712 please create a new bug report in this repository to track this issue. This issue is meant for gathering feedback for early amplify-flutter development only.

@Amplifiyer
Copy link
Contributor Author

Closing this issue since Amplify for flutter is in GA.

@aws-amplify aws-amplify locked and limited conversation to collaborators Mar 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request A request for a new feature or an enhancement to an existing API or category.
Projects
None yet
Development

No branches or pull requests