func GenerateUserToken(ctx context.Context, tokenEndpoint string, configuration loginConfiguration, username string, userSecret string) (*app.AuthToken, error) {
	if !configuration.IsPostgresDeveloperModeEnabled() {
		log.Error(ctx, map[string]interface{}{
			"method": "Generate",
		}, "Postgres developer mode not enabled")
		return nil, errors.NewInternalError("Postgres developer mode is not enabled")
	}

	var scopes []account.Identity
	scopes = append(scopes, test.TestIdentity)
	scopes = append(scopes, test.TestObserverIdentity)

	client := &http.Client{Timeout: 10 * time.Second}

	res, err := client.PostForm(tokenEndpoint, url.Values{
		"client_id":     {configuration.GetKeycloakClientID()},
		"client_secret": {configuration.GetKeycloakSecret()},
		"username":      {username},
		"password":      {userSecret},
		"grant_type":    {"password"},
	})
	if err != nil {
		return nil, errors.NewInternalError("error when obtaining token " + err.Error())
	}

	token, err := auth.ReadToken(res)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"token_endpoint": res,
			"err":            err,
		}, "Error when unmarshal json with access token")
		return nil, errors.NewInternalError("error when unmarshal json with access token " + err.Error())
	}

	return &app.AuthToken{Token: token}, nil
}
// GenerateUserToken obtains the access token from Keycloak for the user
GenerateUserToken obtains the access token from Keycloak for the user
// GenerateUserToken obtains the access token from Keycloak for the user
func GenerateUserToken(ctx context.Context, tokenEndpoint string, configuration loginConfiguration, username string, userSecret string) (*app.AuthToken, error) {
	if !configuration.IsPostgresDeveloperModeEnabled() {
		log.Error(ctx, map[string]interface{}{
			"method": "Generate",
		}, "Postgres developer mode not enabled")
		return nil, errors.NewInternalError("Postgres developer mode is not enabled")
	}
	var scopes []account.Identity
	scopes = append(scopes, test.TestIdentity)
	scopes = append(scopes, test.TestObserverIdentity)
	client := &http.Client{Timeout: 10 * time.Second}
	res, err := client.PostForm(tokenEndpoint, url.Values{
		"client_id":     {configuration.GetKeycloakClientID()},
		"client_secret": {configuration.GetKeycloakSecret()},
		"username":      {username},
		"password":      {userSecret},
		"grant_type":    {"password"},
	})
	if err != nil {
		return nil, errors.NewInternalError("error when obtaining token " + err.Error())
	}
	token, err := auth.ReadToken(res)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"token_endpoint": res,
			"err":            err,
		}, "Error when unmarshal json with access token")
		return nil, errors.NewInternalError("error when unmarshal json with access token " + err.Error())
	}
	return &app.AuthToken{Token: token}, nil
}
func GenerateUserToken ( ctx context . Context , tokenEndpoint string , configuration loginConfiguration , username string , userSecret string ) ( * app . AuthToken , error ) { if ! configuration . IsPostgresDeveloperModeEnabled ( ) { log . Error ( ctx , map [ string ] interface { } { " " : " " , } , " " ) return nil , errors . NewInternalError ( " " ) } var scopes [ ] account . Identity scopes = append ( scopes , test . TestIdentity ) scopes = append ( scopes , test . TestObserverIdentity ) client := & http . Client { Timeout : 10 * time . Second } res , err := client . PostForm ( tokenEndpoint , url . Values { " " : { configuration . GetKeycloakClientID ( ) } , " " : { configuration . GetKeycloakSecret ( ) } , " " : { username } , " " : { userSecret } , " " : { " " } , } ) if err != nil { return nil , errors . NewInternalError ( " " + err . Error ( ) ) } token , err := auth . ReadToken ( res ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : res , " " : err , } , " " ) return nil , errors . NewInternalError ( " " + err . Error ( ) ) } return & app . AuthToken { Token : token } , nil }
GenerateUserToken obtains the access token from Keycloak for the user
GenerateUserToken obtains the access token from Keycloak for the user