security/controller.go
func (c *OAuth2Controller) Refresh(w http.ResponseWriter, r *http.Request) {
	grantType := r.URL.Query().Get("grant_type")
	refreshToken := r.URL.Query().Get("refresh_token")
	if strings.Compare(grantType, "refresh_token") != 0 {
		http.Error(w, errors.New("Parameter grant_type is required").Error(), http.StatusBadRequest)
		return
	}
	if strings.Compare(refreshToken, "") == 0 {
		http.Error(w, errors.New("Parameter refreshToken is required").Error(), http.StatusBadRequest)
		return
	}
	token, err := jwt.Parse(refreshToken, func(token *jwt.Token) (interface{}, error) {
		if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
			return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
		}
		return []byte(c.cnf.Jwt.Key), nil
	})
	if err == nil && token.Valid {
		token := jwt.New(jwt.GetSigningMethod("HS256"))
		claims := token.Claims.(jwt.MapClaims)
		claims["exp"] = time.Now().Add(time.Hour * 1).Unix()
		tokenString, _ := token.SignedString([]byte(c.cnf.Jwt.Key))

		data := map[string]string{
			"access_token": tokenString,
			"token_type":   "bearer",
			"expires_in":   "3600",
		}
		js, _ := json.Marshal(data)
		w.Write(js)
	}
}
func (c *OAuth2Controller) Refresh(w http.ResponseWriter, r *http.Request) {
	grantType := r.URL.Query().Get("grant_type")
	refreshToken := r.URL.Query().Get("refresh_token")
	if strings.Compare(grantType, "refresh_token") != 0 {
		http.Error(w, errors.New("Parameter grant_type is required").Error(), http.StatusBadRequest)
		return
	}
	if strings.Compare(refreshToken, "") == 0 {
		http.Error(w, errors.New("Parameter refreshToken is required").Error(), http.StatusBadRequest)
		return
	}
	token, err := jwt.Parse(refreshToken, func(token *jwt.Token) (interface{}, error) {
		if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
			return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
		}
		return []byte(c.cnf.Jwt.Key), nil
	})
	if err == nil && token.Valid {
		token := jwt.New(jwt.GetSigningMethod("HS256"))
		claims := token.Claims.(jwt.MapClaims)
		claims["exp"] = time.Now().Add(time.Hour * 1).Unix()
		tokenString, _ := token.SignedString([]byte(c.cnf.Jwt.Key))

		data := map[string]string{
			"access_token": tokenString,
			"token_type":   "bearer",
			"expires_in":   "3600",
		}
		js, _ := json.Marshal(data)
		w.Write(js)
	}
}
//Refresh returns a new access token