module
Version:
v0.0.0-...-80b836d
Opens a new window with list of versions in this module.
Published: Jul 27, 2024
License: MIT
Opens a new window with license information.
README
¶
OAuth2 Authentication with Golang and React
This project demonstrates OAuth2 authentication using Golang for the backend API and React for the frontend application.
Getting Started
Prerequisites:
Installation:
-
Clone this repository:
git clone https://github.com/iarsham/oauth2-example.git
-
Navigate to the project directory:
cd oauth2-example
-
Install Go dependencies:
go mod download
-
Install React dependencies:
cd client
npm install
Configuration
-
Provider Registration:
- Visit your chosen provider's developer console (e.g., Google Cloud Platform for Google OAuth2).
- Create a new project or select an existing one.
- Enable the OAuth2 API for your project.
- Create OAuth credentials, specifying:
- Authorized JavaScript origins: The URL of your React application (e.g., http://localhost:3000).
- Authorized redirect URIs: A redirect URI where the provider will send the authorization code after successful login (e.g., http://localhost:3000).
- Copy the Client ID and Client Secret provided by the provider.
-
Add yaml properties in configs folder (Golang):
- Fill the variables with your specific value(Postgres user, password, ...):
- Also fill Client-ID in client/src/index.tsx for integrate with google and backend
Running the Application
-
Start the Golang backend server:
go run ./cmd/web
-
Start the React development server:
cd client
npm start
-
Access your React application in a web browser (usually http://localhost:3000).
Directories
¶
Click to show internal directories.
Click to hide internal directories.