I've built out a React Native app which uses my Rails app as a back end, and I have gotten to the point where I need to get authentication working. The user needs to be able to log in the same way they would via the rails app which uses Devise. I am unclear how to implement that in React Native/iOS.
Ensure the "Google" sign-in provider is enabled on the Firebase Console. import { GoogleSignin } from '@react-native-google-signin/google-signin'; GoogleSignin. configure({ webClientId: '', }); Once initialized, setup your application to trigger a sign-in request with Google using the signIn method.
First, you need to add the gem to your gemfile by running the command gem 'react-rails' and install the gem by running bundle install and react-rails installation script: rails g react:install . These actions will create a directory for the components and manifest file, and add them to the application.
you need to use the token authentication. Look at the Authentication section of this great tutorial, you'll find a basic implementation with the Devise: http://fancypixel.github.io/blog/2015/01/28/react-plus-flux-backed-by-rails-api/
Basically, once you have set up the token auth on the backend, you put a login form in your react native app, on submit you send the creds to the backend and receive the token which you then store in your app state (or you can persist it in asyncstore). Then you attach the token to each request to the backend in a HTTP header.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With