func (cs *ClientStore) GetByID(id string) (info oauth2.ClientInfo, err error) {
	cs.cHandler(cs.ccfg.ClientsCName, func(c *mgo.Collection) {
		entity := new(client)
		if cerr := c.FindId(id).One(entity); cerr != nil {
			err = cerr
			return
		}
		info = &models.Client{
			ID:     entity.ID,
			Secret: entity.Secret,
			Domain: entity.Domain,
			UserID: entity.UserID,
		}
	})
	return
}
GetByID according to the ID for the client information
package mongo
import (
	"github.com/globalsign/mgo"
	"gopkg.in/oauth2.v3"
	"gopkg.in/oauth2.v3/models"
)
type ClientConfig struct {
	ClientsCName string
}
func NewDefaultClientConfig() *ClientConfig {
	return &ClientConfig{
		ClientsCName: "oauth2_clients",
	}
}
func NewClientStore(cfg *Config, ccfgs ...*ClientConfig) *ClientStore {
	session, err := mgo.Dial(cfg.URL)
	if err != nil {
		panic(err)
	}
	return NewClientStoreWithSession(session, cfg.DB, ccfgs...)
}
func NewClientStoreWithSession(session *mgo.Session, dbName string, ccfgs ...*ClientConfig) *ClientStore {
	cs := &ClientStore{
		dbName:  dbName,
		session: session,
		ccfg:    NewDefaultClientConfig(),
	}
	if len(ccfgs) > 0 {
		cs.ccfg = ccfgs[0]
	}
	return cs
}
type ClientStore struct {
	ccfg    *ClientConfig
	dbName  string
	session *mgo.Session
}
func (cs *ClientStore) Close() {
	cs.session.Close()
}
func (cs *ClientStore) c(name string) *mgo.Collection {
	return cs.session.DB(cs.dbName).C(name)
}
func (cs *ClientStore) cHandler(name string, handler func(c *mgo.Collection)) {
	session := cs.session.Clone()
	defer session.Close()
	handler(session.DB(cs.dbName).C(name))
	return
}
func (cs *ClientStore) Set(info oauth2.ClientInfo) (err error) {
	cs.cHandler(cs.ccfg.ClientsCName, func(c *mgo.Collection) {
		entity := &client{
			ID:     info.GetID(),
			Secret: info.GetSecret(),
			Domain: info.GetDomain(),
			UserID: info.GetUserID(),
		}
		if cerr := c.Insert(entity); cerr != nil {
			err = cerr
			return
		}
	})
	return
}