Categorygithub.com/Ekliptor/go-oauth2-mysql
modulepackage
1.1.3
Repository: https://github.com/ekliptor/go-oauth2-mysql.git
Documentation: pkg.go.dev

# README

MySQL Storage for OAuth 2.0

Build Codecov GoDoc License

Install

$ go get -u -v github.com/imrenagi/go-oauth2-mysql

MySQL drivers

The store accepts an sqlx.DB which interacts with the DB. sqlx.DB is a specific implementations from github.com/jmoiron/sqlx

Usage example

package main

import (
	_ "github.com/go-sql-driver/mysql"
	mysql "github.com/imrenagi/go-oauth2-mysql"
	"github.com/jmoiron/sqlx"
)

func main() {
	db, err := sqlx.Connect("mysql", "user:password@tcp(127.0.0.1:3306)/oauth_db?parseTime=true")
	if err != nil {
		log.Fatalln(err)
	}

	clientStore, _ := mysql.NewClientStore(db, mysql.WithClientStoreTableName("custom_table_name"))
	tokenStore, _ := mysql.NewTokenStore(db)
}

How to run tests

You will need running MySQL instance. E.g. the one running in docker and exposing a port to a host system

$ docker run -it  -p 3306:3306 -e MYSQL_ROOT_PASSWORD=oauth2 -d mysql
$ docker exec -it <container_id> bash
$ mysql -u root -poauth2
> create database oauth_db
$ MYSQL_URI=root:oauth2@tcp(127.0.0.1:3306)/oauth_db?parseTime=true go test .

MIT License

Copyright (c) 2019 Imre Nagi

Credits

# Functions

NewClientStore creates PostgreSQL store instance.
NewTokenStore creates PostgreSQL store instance.
WithClientStoreInitTableDisabled returns option that disables table creation on client store instantiation.
WithClientStoreTableName returns option that sets client store table name.
WithTokenStoreGCDisabled returns option that disables token store garbage collection.
WithTokenStoreGCInterval returns option that sets token store garbage collection interval.
WithTokenStoreInitTableDisabled returns option that disables table creation on token store instantiation.
WithTokenStoreTableName returns option that sets token store table name.

# Structs

No description provided by the author
ClientStoreItem data item.
No description provided by the author
TokenStoreItem data item.

# Type aliases

ClientStoreOption is the configuration options type for client store.
TokenStoreOption is the configuration options type for token store.