modulepackage
4.2.0
Repository: https://github.com/passwind/go-oauth2-mysql.git
Documentation: pkg.go.dev
# README
MySQL Storage/v4 for OAuth 2.0
V4 Branch is suitable for github.com/go-oauth2/oauth2/v4
Install
$ go get -u -v github.com/passwind/go-oauth2-mysql/v4
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
- MySQL Storage for OAuth 2.0
https://github.com/imrenagi/go-oauth2-mysql
- Oauth Postgres Implementation
github.com/vgarvardt/go-pg-adapter
# 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.