- Notifications
You must be signed in to change notification settings - Fork153
alexmngn/react-native-authentication
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The main goal of this project is to show you how to register and authenticate a user and access protected resources from a React-Native app to a NodeJS server.
If you want to know more about this project, you can read this article which describe how it works:
The Essential Boilerplate to Authenticate Users on your React-Native app.
https://medium.com/@alexmngn/the-essential-boilerplate-to-authenticate-users-on-your-react-native-app-f7a8e0e04a42
This project has been tested with Node v6.0.0 and NPM 3.8.6.
If you don't have React-Native installed on your computer, run the following:
npm install -g react-native-cliGo in theclient/MobileApp directory, and run the following:
npm installiOS:
react-native run-iosAndroid:
You will need to follow a few steps to run the client:
- Open the file
client/MobileApp/src/services/api/config.js - Modify
localhostwith the IP address of your machine (usually something like 192.168.0.10)
export default {clientId: '8puWuJWZYls1Ylawxm6CMiYREhsGGSyw',url: 'http://192.168.0.10:1337',};- Create a file called
local.propertiesin the/MobileApp/androidfolder and add the following line (replace the target with the path to your SDK):sdk.dir = /Users/Alexis/Library/Android/sdk - Open an Emulator (from Android Studio) or plug an Android device on your computer.
- Then you can run the following in terminal:
react-native run-androidYou can login with the following user:
- Email:user1@facebook.com
- Password:12345678
There is also a Client-ID that has already been generated, currently hard-coded in the client api config:
- 8puWuJWZYls1Ylawxm6CMiYREhsGGSyw
If you don't have SailsJS installed on your computer, run the following:
npm install -g sailsGo in theserver directory, then run the following:
npm installRun the following in the terminal:
sails liftThis will create a server listening on port 3000, you can access it fromhttp://localhost:3000/. The server needs to run at all time when you use the client.
An open entry-point is provided to generate this ID. This should not be done in production:
POST /clients
The non-protected entry-points allow authentication and registration:
POST /users: Create a new userPOST /users/auth: Authenticate and retrieve the access and refresh tokens in exchange of email/passwordPOST /users/auth/refresh: Authenticate and retrieve the access token in exchange of the refresh token.
The protected entry-point allows everything else:
GET /users: Retrieve the list of usersPOST /users/auth/revoke: Log out, revoke access by destroying the user tokens
About
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.