func showAPIToken(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	u, err := auth.ConvertNewUser(t.User())
	if err != nil {
		return err
	}
	email := r.URL.Query().Get("user")
	if email != "" {
		if !permission.Check(t, permission.PermUserUpdateToken) {
			return permission.ErrUnauthorized
		}
		u, err = auth.GetUserByEmail(email)
		if err != nil {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
	}
	apiKey, err := u.ShowAPIKey()
	if err != nil {
		return err
	}
	w.Header().Add("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(apiKey)
}
func showAPIToken(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	u, err := auth.ConvertNewUser(t.User())
	if err != nil {
		return err
	}
	email := r.URL.Query().Get("user")
	if email != "" {
		if !permission.Check(t, permission.PermUserUpdateToken) {
			return permission.ErrUnauthorized
		}
		u, err = auth.GetUserByEmail(email)
		if err != nil {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
	}
	apiKey, err := u.ShowAPIKey()
	if err != nil {
		return err
	}
	w.Header().Add("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(apiKey)
}
func showAPIToken ( w http . ResponseWriter , r * http . Request , t auth . Token ) error { u , err := auth . ConvertNewUser ( t . User ( ) ) if err != nil { return err } email := r . URL . Query ( ) . Get ( " " ) if email != " " { if ! permission . Check ( t , permission . PermUserUpdateToken ) { return permission . ErrUnauthorized } u , err = auth . GetUserByEmail ( email ) if err != nil { return & errors . HTTP { Code : http . StatusNotFound , Message : err . Error ( ) } } } apiKey , err := u . ShowAPIKey ( ) if err != nil { return err } w . Header ( ) . Add ( " " , " " ) return json . NewEncoder ( w ) . Encode ( apiKey ) }
// title: show token
// path: /users/api-key
// method: GET
// produce: application/json
// responses:
//   200: OK
//   401: Unauthorized
//   404: User not found
title : show token path : / users / api - key method : GET produce : application / json responses : 200 : OK 401 : Unauthorized 404 : User not found