Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement custom identity authorization with AWS Amplify (Flutter or JS)

In the iOS AWSCore library one can authorize bespoke third-party auth systems into an AWS identity pool roughly as follows:

let myIdProvider = MyCustomIdProvider()
let credentialsProvider = AWSCognitoCredentialsProvider(regionType: AWSRegionType.USWest2, identityProvider: myIdProvider)
let configuration = AWSServiceConfiguration(region: AWSRegionType.USWest2, credentialsProvider:credentialsProvider)!
// which is then used for things like S3 access...

// The custom provider class...
class MyCustomIdProvider : AWSCognitoCredentialsProviderHelper {
   override func token() -> AWSTask<NSString> {
       // Do the verification here
   }
}

I want to move this code to a cross-platform solution (in Dart/Flutter ideally but happy with a JS solution for now). How can I accomplish that in Amplify?

like image 825
Hari Honor Avatar asked Oct 16 '25 23:10

Hari Honor


1 Answers

You can use the following steps, in short, you really not required the above code when working with AWS Cognito amplify API this API provides abstraction and make your life simple.

  1. You need to create an Identity pool

enter image description here

  • https://aws.amazon.com/blogs/mobile/building-an-application-with-aws-amplify-amazon-cognito-and-an-openid-connect-identity-provider/
  • https://docs.aws.amazon.com/cognito/latest/developerguide/identity-pools.html
  1. The Amplify Framework uses Amazon Cognito as the main authentication provider. Amazon Cognito is a robust user directory service that handles user registration, authentication, account recovery & other operations. In this tutorial, you'll learn how to add authentication to your application using Amazon Cognito and username/password login.

Following is an example in react.js but you can use the same in your code as its using simple JavaScript, you can download and add your user pool details in config.json and check in local

Code example:

  • https://github.com/vaquarkhan/aws-cognito-amplify-reactjs-poc/tree/main/src

  • https://docs.amplify.aws/lib/auth/getting-started/q/platform/js/

like image 152
vaquar khan Avatar answered Oct 18 '25 13:10

vaquar khan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!