// ValidationTokenRequest the token request validation, add user client scope validation
ValidationTokenRequest the token request validation, add user client scope validation
// ValidationTokenRequest the token request validation add user client scope validation
func (s *Oauth2Server) ValidationTokenRequest(r *http.Request) (gt oauth2.GrantType, tgr *oauth2.TokenGenerateRequest, err error) {
	gt = oauth2.GrantType(r.FormValue("grant_type"))
	if fn, ok := customGrantRequestValidatorMap[gt]; ok {
		gt, tgr, err = fn(r)
	} else {
		gt, tgr, err = s.Server.ValidationTokenRequest(r)
	}
	if err != nil {
		return
	}
	if tgr.Scope == "" || gt != oauth2.PasswordCredentials {
		return
	}
	user, err := s.userStore.Find(tgr.UserID)
	if err != nil {
		return
	}
	scope, ok := user.GetScopes()[tgr.ClientID]
	if ok && o2x.ScopeContains(scope, tgr.Scope) {
		return
	}
	glog.Errorf("the scope of user [%v] for client [%v] is [%v], but request [%v]", tgr.UserID, tgr.ClientID, scope, tgr.Scope)
	err = errors.ErrInvalidScope
	return
}
func ( s * Oauth2Server ) ValidationTokenRequest ( r * http . Request ) ( gt oauth2 . GrantType , tgr * oauth2 . TokenGenerateRequest , err error ) { gt = oauth2 . GrantType ( r . FormValue ( " " ) ) if fn , ok := customGrantRequestValidatorMap [ gt ] ; ok { gt , tgr , err = fn ( r ) } else { gt , tgr , err = s . Server . ValidationTokenRequest ( r ) } if err != nil { return } if tgr . Scope == " " || gt != oauth2 . PasswordCredentials { return } user , err := s . userStore . Find ( tgr . UserID ) if err != nil { return } scope , ok := user . GetScopes ( ) [ tgr . ClientID ] if ok && o2x . ScopeContains ( scope , tgr . Scope ) { return } glog . Errorf ( " " , tgr . UserID , tgr . ClientID , scope , tgr . Scope ) err = errors . ErrInvalidScope return }
ValidationTokenRequest the token request validation, add user client scope validation
ValidationTokenRequest the token request validation add user client scope validation
// check whether need scope check