go-client icon indicating copy to clipboard operation
go-client copied to clipboard

register a user to an application

Open smilad opened this issue 2 years ago • 1 comments

when i want to register user to and application I have a error and give me that user exist: package main

import ( "github.com/FusionAuth/go-client/pkg/fusionauth" "log" "net/http" "net/url" )

func main() { var HttpClient = &http.Client{}

u, _ := url.Parse("http://192.168.13.32:9011")
f := fusionauth.NewClient(HttpClient, u, "hBUKq3x_hUFXqA6GSXhdWWTRknTq7uzTNc_SzCmhpgDgm0UpNI-Wm56C")

r, e1, e2 := f.Register("e2337690-4c91-4573-bbed-88695701612f", fusionauth.RegistrationRequest{
	Registration: fusionauth.UserRegistration{
		ApplicationId: "dee6cf94-0bdc-4050-bca8-04ac1920ee9b",
		Username:      "dtd",
		Roles:         []string{"10"},
	},
})

log.Println("response", r)
log.Println("des err : ", e1)
log.Println("err", e2)

}

and my error is:

user.email: You must specify either the [user.email] or [user.username] property. If you are emailing the user you must specify the [user.email]. user.password: You must specify the [user.password] property. user.username: You must specify either the [user.email] or [user.username] property. If you are emailing the user you must specify the [user.email]. userId: A User with Id [e2337690-4c91-4573-bbed-88695701612f] already exists.

smilad avatar Oct 17 '23 15:10 smilad

I have this same error.

faRegistrationReq := fusionauth.RegistrationRequest{
	SkipRegistrationVerification: true,
	SkipVerification:             true,
	Registration: fusionauth.UserRegistration{
		Id:            registration.ID,
		ApplicationId: registration.ApplicationID,
		Roles:         roles,
	},
}

resp, faErrs, err := s.faClient.Register(registration.UserID, faRegistrationReq)

Serialization of the RegistrationRequest struct shows:

{
  "eventInfo": {
    "location": {}
  },
  "disableDomainBlock": false,
  "generateAuthenticationToken": false,
  "registration": {
    "applicationId": "15fd0844-6668-425f-b9f9-0f781df2edfd",
    "id": "da07f7b5-f46a-4b9f-bd84-2298083bdee0",
    "verified": false
  },
  "sendSetPasswordEmail": false,
  "skipRegistrationVerification": true,
  "skipVerification": true,
  "user": {
    "passwordChangeRequired": false,
    "verified": false,
    "active": false,
    "twoFactor": {}
  }
}

This is on version 1.57.1 of the sdk.

john-peterson-g17 avatar May 07 '25 19:05 john-peterson-g17