func GetUserInfo(ctx context.Context, userInfoEndpoint string, userAccessToken string) (*UserInfo, error) {
	req, err := http.NewRequest("GET", userInfoEndpoint, nil)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "Unable to crete http request")
		return nil, errors.NewInternalError("unable to crete http request " + err.Error())
	}
	req.Header.Add("Authorization", "Bearer "+userAccessToken)
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "Unable to get user info from Keycloak")
		return nil, errors.NewInternalError("Unable to get user info from Keycloak " + err.Error())
	}
	if res.StatusCode != http.StatusOK {
		log.Error(ctx, map[string]interface{}{}, "Unable to get user info from Keycloak")
		return nil, errors.NewInternalError("Unable to get user info from Keycloak. Response status: " + res.Status + ". Responce body: " + rest.ReadBody(res.Body))
	}
	jsonString := rest.ReadBody(res.Body)

	var r UserInfo
	err = json.Unmarshal([]byte(jsonString), &r)
	if err != nil {
		return nil, errors.NewInternalError(fmt.Sprintf("error when unmarshal json with user info payload: \"%s\" ", jsonString) + err.Error())
	}

	return &r, nil
}
// GetUserInfo gets user info from Keycloak
GetUserInfo gets user info from Keycloak
// GetUserInfo gets user info from Keycloak
func GetUserInfo(ctx context.Context, userInfoEndpoint string, userAccessToken string) (*UserInfo, error) {
	req, err := http.NewRequest("GET", userInfoEndpoint, nil)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "Unable to crete http request")
		return nil, errors.NewInternalError("unable to crete http request " + err.Error())
	}
	req.Header.Add("Authorization", "Bearer "+userAccessToken)
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"err": err.Error(),
		}, "Unable to get user info from Keycloak")
		return nil, errors.NewInternalError("Unable to get user info from Keycloak " + err.Error())
	}
	if res.StatusCode != http.StatusOK {
		log.Error(ctx, map[string]interface{}{}, "Unable to get user info from Keycloak")
		return nil, errors.NewInternalError("Unable to get user info from Keycloak. Response status: " + res.Status + ". Responce body: " + rest.ReadBody(res.Body))
	}
	jsonString := rest.ReadBody(res.Body)
	var r UserInfo
	err = json.Unmarshal([]byte(jsonString), &r)
	if err != nil {
		return nil, errors.NewInternalError(fmt.Sprintf("error when unmarshal json with user info payload: \"%s\" ", jsonString) + err.Error())
	}
	return &r, nil
}
func GetUserInfo ( ctx context . Context , userInfoEndpoint string , userAccessToken string ) ( * UserInfo , error ) { req , err := http . NewRequest ( " " , userInfoEndpoint , nil ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : err . Error ( ) , } , " " ) return nil , errors . NewInternalError ( " " + err . Error ( ) ) } req . Header . Add ( " " , " " + userAccessToken ) res , err := http . DefaultClient . Do ( req ) if err != nil { log . Error ( ctx , map [ string ] interface { } { " " : err . Error ( ) , } , " " ) return nil , errors . NewInternalError ( " " + err . Error ( ) ) } if res . StatusCode != http . StatusOK { log . Error ( ctx , map [ string ] interface { } { } , " " ) return nil , errors . NewInternalError ( " " + res . Status + " " + rest . ReadBody ( res . Body ) ) } jsonString := rest . ReadBody ( res . Body ) var r UserInfo err = json . Unmarshal ( [ ] byte ( jsonString ) , & r ) if err != nil { return nil , errors . NewInternalError ( fmt . Sprintf ( " \" \" " , jsonString ) + err . Error ( ) ) } return & r , nil }
GetUserInfo gets user info from Keycloak
GetUserInfo gets user info from Keycloak