//InitOauth2Server initial a oauth2 server with storage services
InitOauth2Server initial a oauth2 server with storage services
// InitOauth2Server initial a oauth2 server with storage services
func InitOauth2Server(cs oauth2.ClientStore, ts oauth2.TokenStore, us o2x.UserStore, as o2x.AuthStore,
	cfg *ServerConfig, mapper HandleMapper) *Oauth2Server {
	if cs == nil || ts == nil || us == nil {
		panic("store is nil")
	}
	InitServerConfig(cfg, mapper)
	oauth2Mgr = manage.NewDefaultManager()
	if cfg.JWTSupport {
		oauth2Mgr.MapAccessGenerate(jwtex.NewJWTAccessGenerate(cfg.JWT))
	}
	oauth2Mgr.MustTokenStorage(ts, nil)
	oauth2Mgr.MustClientStorage(cs, nil)
	defaultTokenConfig(oauth2Mgr)
	oauth2Svr = NewServer(&server.Config{
		TokenType:            "Bearer",
		AllowedResponseTypes: []oauth2.ResponseType{oauth2.Code, oauth2.Token},
		AllowedGrantTypes: []oauth2.GrantType{
			oauth2.AuthorizationCode,
			oauth2.PasswordCredentials,
			oauth2.ClientCredentials,
			oauth2.Refreshing,
			oauth2.Implicit,
		},
	}, oauth2Mgr)
	oauth2Svr.clientStore = cs
	oauth2Svr.tokenStore = ts
	oauth2Svr.userStore = us
	if as == nil {
		as = o2x.NewAuthStore()
	}
	oauth2Svr.authStore = as
	oauth2Svr.o2xTokenStore, oauth2Svr.o2xTokenAccountSupport = ts.(o2x.O2TokenStore)
	oauth2Svr.mapper = mapper
	oauth2Svr.cfg = cfg
	oauth2Svr.SetAllowGetAccessRequest(true)
	oauth2Svr.SetClientInfoHandler(server.ClientBasicHandler)
	oauth2Svr.SetPasswordAuthorizationHandler(PasswordAuthorizationHandler)
	oauth2Svr.SetUserAuthorizationHandler(userAuthorizeHandler)
	oauth2Svr.SetInternalErrorHandler(InternalErrorHandler)
	oauth2Svr.SetResponseErrorHandler(ResponseErrorHandler)
	oauth2Svr.SetClientScopeHandler(ClientScopeHandler)
	oauth2Svr.SetClientAuthorizedHandler(ClientAuthorizedHandler)
	oauth2Svr.SetRefreshingScopeHandler(RefreshingScopeHandler)
	oauth2Svr.SetAuthorizeScopeHandler(AuthorizeScopeHandler)
	return oauth2Svr
}
func InitOauth2Server ( cs oauth2 . ClientStore , ts oauth2 . TokenStore , us o2x . UserStore , as o2x . AuthStore , cfg * ServerConfig , mapper HandleMapper ) * Oauth2Server { if cs == nil || ts == nil || us == nil { panic ( " " ) } InitServerConfig ( cfg , mapper ) oauth2Mgr = manage . NewDefaultManager ( ) if cfg . JWTSupport { oauth2Mgr . MapAccessGenerate ( jwtex . NewJWTAccessGenerate ( cfg . JWT ) ) } oauth2Mgr . MustTokenStorage ( ts , nil ) oauth2Mgr . MustClientStorage ( cs , nil ) defaultTokenConfig ( oauth2Mgr ) oauth2Svr = NewServer ( & server . Config { TokenType : " " , AllowedResponseTypes : [ ] oauth2 . ResponseType { oauth2 . Code , oauth2 . Token } , AllowedGrantTypes : [ ] oauth2 . GrantType { oauth2 . AuthorizationCode , oauth2 . PasswordCredentials , oauth2 . ClientCredentials , oauth2 . Refreshing , oauth2 . Implicit , } , } , oauth2Mgr ) oauth2Svr . clientStore = cs oauth2Svr . tokenStore = ts oauth2Svr . userStore = us if as == nil { as = o2x . NewAuthStore ( ) } oauth2Svr . authStore = as oauth2Svr . o2xTokenStore , oauth2Svr . o2xTokenAccountSupport = ts . ( o2x . O2TokenStore ) oauth2Svr . mapper = mapper oauth2Svr . cfg = cfg oauth2Svr . SetAllowGetAccessRequest ( true ) oauth2Svr . SetClientInfoHandler ( server . ClientBasicHandler ) oauth2Svr . SetPasswordAuthorizationHandler ( PasswordAuthorizationHandler ) oauth2Svr . SetUserAuthorizationHandler ( userAuthorizeHandler ) oauth2Svr . SetInternalErrorHandler ( InternalErrorHandler ) oauth2Svr . SetResponseErrorHandler ( ResponseErrorHandler ) oauth2Svr . SetClientScopeHandler ( ClientScopeHandler ) oauth2Svr . SetClientAuthorizedHandler ( ClientAuthorizedHandler ) oauth2Svr . SetRefreshingScopeHandler ( RefreshingScopeHandler ) oauth2Svr . SetAuthorizeScopeHandler ( AuthorizeScopeHandler ) return oauth2Svr }
InitOauth2Server initial a oauth2 server with storage services
InitOauth2Server initial a oauth2 server with storage services
// set mapper // set cfg