Persisting unauthenticated user on AWS Cognito and AWS Amplify with React Native - amazon-cognito

I'm trying to implement AWS-Amplify in a React Native app so that events can be sent to Pinpoint for analytics. A user doesn't need to be signed in to use the app, so they would be unauthenticated with Cognito.
I am noticing that the identity of the unauthenticated user doesn't seem to persist, so when I close or uninstall the app, a new identity id is generated when I launch the app. The docs suggest that this should be cached, but it seems the cache is clearing out when using AWS Amplify.
Is there a way to set or reuse an identity id for a returning unauthenticated user on AWS-Amplify or Cognito so new identity ids don't get assigned ?
I looked through amazon-cognito-identity-js to see if there was a way to do this with an unauthenticated user and wasn't able to find what I am describing: see here.
I'm new to AWS Amplify/Cognito/Pinpoint in general, so any thoughts or suggestions to do something similar would be greatly appreciated!

This is a known issue in the AWS Amplify and should have been fixed in the latest version.

Related

AWS Cognito with social login Google, Facebook, Apple and react native

I'm working currently on the implementation of social login using react-native and aws cognito. For now, it's working well (with or without amplify), but the issue is that I have to open a webview using the cognito hosted UI, which redirect directly to Google / Facebook / Apple. So basically, when the user click on the google signin button, there is a messagethis kind of message "myapp wants to open amazoncognito to connect...". As a user experience, it is quite mediocre, so I am wondering if it is possible to implement a different signin flow so not to redirect to an external url.
I have tried the implemntation with react-native-google-signin, but in that case, I have to use aws federated identities instead of my user pool (typically, the gogole signin retrieve an id token that can be pass to cognito federated identities). So I do not really like that solution...
I don't know exactly the process of signing up with a social login provider but if someone has ever met the issue and found a user friendly way to implement it, I am obviously interested in the solution ! (One option would be to figure out how to use the IdToken generated by Google to sign the user in my Cognito user pool, the other would be to directly use an iframe to open facebook, google, apple, so at least the message would not appear).
Thank you for you help !

How to enable email and password signin provider for new firebase project using gcloud console or firebase tools CLI?

In the company I am working for, we provide a solution for other companies, and we want each company to have a separate instance of that solution, this includes a separate database instance, the database is Firebase, this choice of creating a new separate instance is required due to data privacy laws of the country we work in.
I am working on a script that when triggered by the new client SignUp, it starts the creation of new solution instance, including the creation of the new Firebase project, and I am using firebase-tools CLI and gcloud CLI.
The project creation happens correctly, and the admin account is created, the only remaining thing is to allow the admin to be able to login to the new Firebase project. This is usually done manually from the Firebase web console, by enabling a login provider, an Email&Password login provider in my case. This part of the process is so not automated, because I can't find the command that I should pass to Firebase-tools or gcloud ClI to enable a login provider in a Firebase project.
What is a command that you can pass to Firebase tools or to gcloud CLI , to change firebase project confguration to enable a signin provider ? signin usng Email&Passsword in this case .. Or is there a way to do it programmatically using Google client libraries ?
From looking at the REST API for the Google Identify Platform, I don't immediately see a call that shows email+password authentication. Unless I'm overlooking something this means it might not be possible to programmatically enable this provider through a public API.
From checking what the Firebase console does, it seems it handles the provider configuration through the https://identitytoolkit.clients6.google.com/admin/v2/projects/<projectid>/config endpoint, but I'm not sure that is part of the public API.
This seems possible now via Identity Toolkit API. The v2.projects REST resource has updateConfig method, and the Config contains SignInConfig which have the Email property.

AWS amplify authentication, enable only sign in - not sign up

From all the great tutorials I looked for of how to add an auth module for a react app in amplify. The only type of module I see is a complete feature of sign in + sign up.
What I'm trying to achieve is:
Set up a custom Cognito user pool and add users to the pool manually.
Add custom sign-in/login UI + code to a react amplify app.
Disable anyone but me to add new users to the Cognito user pool manually.
The website I'm working on is an internal website and I don't want anyone to be able to sign up via AppSync or the react client.
Please help :)
This won't be very difficult - you simply don't implement the front-end functionality to add a new user. Then, in your Cognito user pool config, there is an option User sign ups allowed? which you would set to Only administrators can create users.
Edit: Also, consider using the hosted UI, it may save you some front-end work.

Delete the user pool added by AWS Amplify

I'm developing a React Native app and using AWS Amplify with Amazon Cognito for authentication. I've added the authentication for the app using Amplify CLI (amplify add auth). The problem is I need to add/remove the required attributes for the sign up, but those cannot be changed after the user pool is created.
My question is how can I delete the currently added user pool using the CLI, and making sure that the changes are reflected in aws-exports.js?
I figured it out. As mentioned here, it's not in amplify-cli docs, but you can remove a single category (in this case auth) like this:
amplify remove <category>
So, in this case, it would be
amplify remove auth
And, then
amplify push
aws cognito-idp delete-user-pool --user-pool-id youruserpoolid

How to connect my react native app to existing database using Amplify?

I have react native app that already at the store.
I decided to move my database and my frontend and backend using Amplify.
I would like to connect my react native app using Amplify too, my needs are to check if user is sign in and get access token, refresh token, token expired date, sign out and using the different apis on the backend to get data...
I was looking on different documents like this one but couldn't find a way to connect to exist one, the only option I have seen is to create a new database only for the mobile...
What are my options? I thought maybe I should create login and refreshToken functions in the backend and only call those functions every time I need to log in or refresh a token... or maybe I should use configuration file somewhere? I was thinking about this file awsExports but not sure this is the right one, there's no explanation about it
Thanks in advance