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
Related
In order to quickly prototype ideas for a personal project I'm interested in a solution where I use Prisma directly from a react native app. (I'm aware this is not something you'd do in production.) Data for the single user app would be stored in some free SQL cloud DB. I would store auth information locally in the client.
Is this possible just like it would be possible in a nodejs Cli or webapp?
Currently Prisma only works on servers so you would need to use it on Node. There's a request for react-native support so you can add upvote the request.
We are rebuilding an Ionic 1.x application with React Native. The app is used by a lot of people and I don't want everyone to log in again after they update the app.
The current app uses localStorage to save the token that defines if a user is logged in (I know, it's not the safest method). Is there a possibility that we can get the current token from the localStorage in React Native and put in our secure storage?
So basically can we call the localStorage instance in React Native? We are using the same bundle identifier so many there is a possibility to access the localStorage from the old app.
You wont treat with a web enviroment like Ionic, then localStorage wont exist, but you can use AsyncStorage instead in react native or some DB like sqlite, realm, whatermelonDB (the last one I didnt use) to save your user data
I've recently decided to try and make a universal app with expo supporting ios, android and web altogether.
I knew that there would be many hick ups along the way.. but I found the biggest problem from the start.
I can see that there are few options as where to store the access token for apps such as secure store or asyncStorage, I just simply can't find a way to work with cookies or any client side store to put in the access-token.
As my app should have the stay logged in feature essentially, this will be a critical problem for the web client.
Does anybody know a good workaround this matter, or is there a way to keep the users logged in from the server side using the device / ip detail..?
Please enlighten me guys!
The web support is available in asyncStorage since v1.9.0.
So you can use it in recent versions of asyncStorage.
I've managed to do this with AsyncStorage.
import AsyncStorage from '#react-native-community/async-storage';
/// Then inside your component make an asynchronous set
await AsyncStorage.setItem(['tokenName', tokenValue]);
I want to migrate an existing Android+iOS native app to a react-native Expo app.
In current native app, we store an auth token. I'd like this auth token to be available through ReactNative AsyncStorage api out of the box, without requiring RN native code (ie, ejecting Expo).
Is this possible, in current native app, to start writing to the same place as AsyncStorage will read after the migration?
We aim for the smoothest transition from native app to RN app, and user should stay authenticated after the upgrade.
Depends on what you're current app is using for storage. I recently used this library (https://github.com/kevinresol/react-native-default-preference) to get the data from user defaults then move it into async storage. I only migrate the refresh token and auth token.
If they are using core data, then you'll need to setup the same models etc - https://github.com/realm/realm-js/issues/584
The other storage mechanisms you can easily find a native package to get the data.
if the app is under same app name scheme you may be able to access after upgrade i guess.
I am trying to test a react native app on android which uses a native library which does oauth-based authentication using a webview. Detox does not support webviews (yet) so I was wondering if I could tap on the keyboard using coordinates in order to get through the auth (bad I know, but gets me unstuck for now).
Since the oauth screen is outside your app, I'd recommend you do the following:
Create E2E tests for your login up to the oauth screen
Get a CLI for your oauth provider or figure out how to authenticate via node.js to get the auth token
Create a deep link path in your app that accepts the token as a param and stores it the way you'd store it normally and trigger a continuation of the login flow (you may need to reverse engineer your native lib slightly)
This is generally the approach you want to take if you are using an external authentication party. If the party providing the auth package doesn't support 2 and 3, you should raise the issue with them.