Skip to main content

Introduction

⚡️ GAuth can help simplify the authorization login process for third-party platforms.

Currently Supported

Installation

go get github.com/LeoInnovateLab/gauth

Step

  1. Register as a developer account for third-party platforms, such as: GitHub developer account.
  2. Create an application for the third-party platform and obtain configuration information.
    • Client Id
    • Client Secrets
    • Callback URL
  3. Utilize GAuth for authorization login.
// create authorization request
authRequest, err := gauth.New().
Source("github").
ClientId("your_client_id").
ClientSecret("your_client_secret").
RedirectUrl("http://localhost:8080/auth/github/callback").
Build()

// generate authorization URL
authorizeUrl, err := authRequest.Authorize("state")

// After authorization login, it will return login information.
response, err := authRequest.Login(callback)

Demo

Recommend using GAuth Demo for testing.

  • Fill in the requested App Id and App secrets in .env.demo

  • Then, Start project, visit http://localhost:8080/

Demo