This repository provides an example setup for integrating the Okto React SDK. The app demonstrates authentication, token management, and other core functionalities.
- Node.js and npm installed.
- Configure Google OAuth credentials for login.
- Obtain your Okto API Key.
Create a .env
file in the root directory of the frontend project with the following variables:
REACT_APP_OKTO_CLIENT_API_KEY=your_okto_client_api_key
REACT_APP_GOOGLE_CLIENT_ID=your_google_client_id
Create a .env
file in the root directory of the backend server project with the following variables:
CLIENT_ID=your_google_client_id
CLIENT_SECRET=your_google_client_secret
git clone [email protected]:okto-hq/okto-sdk-react-template-app.git
cd okto-sdk-react-template-app
The backend server handles Google OAuth token exchange and refresh using the google-auth-library package. The Backend server must be running for Google authentication in the Onboarding Modal to work.
-
Navigate to the backend directory.
-
Install dependencies:
npm install
-
Create backend
.env
file and add the required keys. -
Start the server:
node okto-gauth-server.js
The backend runs on http://localhost:3001
.
-
Navigate to the frontend project directory.
-
Install dependencies:
npm install
-
Create the frontend
.env
file and add the required keys. -
Start the development server:
npm start
The backend runs on http://localhost:3001
.
-
Start both the frontend and backend servers.
-
Open the app in your browser at
http://localhost:3000
. -
Use available authentication methods and features.
- Ensure both backend and frontend servers are running simultaneously
- Verify all environment variables are correctly set
- Check Google OAuth credentials are properly configured
- Confirm Okto API key is valid