GithubHelp home page GithubHelp logo

go-oauth2's Introduction

Go-OAuth2

Go-OAuth is a Go-based application designed for integrating OAuth2.0 authentication, specifically with Google's OAuth service. It leverages Go's robustness and efficiency to securely manage user authentication and session management using Redis. This solution offers a REST API interface, enabling users to easily authenticate via Google OAuth and manage sessions in a Redis datastore.

Prerequisites

Before setting up Go-OAuth, ensure you have the following:

  • Latest stable version of Go.
  • Access to a Google Cloud Platform account for OAuth 2.0 credentials.

Usage

To start using the OAuth2.0 authentication flow with your application, send a GET request to the authentication endpoint to redirect users to Google's OAuth consent page:

Authentication Endpoint:

GET http://localhost:8080/google_login

Callback Endpoint:

GET http://localhost:8080/google_callback

This endpoint exchanges the authentication code for tokens and establishes a session.

Profile Endpoint:

GET http://localhost:8080/profile

This endpoint returns the logged-in user's profile information.

Configuration

Configure the application through a .env file or environment variables, including:

  • Google OAuth 2.0 credentials (CLIENT_ID, CLIENT_SECRET).

Example of .env configuration:

CLIENT_ID=your_google_client_id
CLIENT_SECRET=your_google_client_secret
JWT_SECRET=your_jwt_secret

Running the Application

  1. Clone the repository and navigate to the project directory.
  2. Ensure all prerequisites are met.
  3. Configure the application as described in the Configuration section.
  4. Run the application:
docker-compose up -d

This starts the server, making the authentication endpoints available for OAuth flows.

go-oauth2's People

Contributors

armaankatyal avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.