| 327 | } |
| 328 | |
| 329 | func selectClientToUseForTestsAndValidateExistence(cli *cli, cmd *cobra.Command, args []string, inputs *testCmdInputs) (*management.Client, error) { |
| 330 | if len(args) == 0 { |
| 331 | if err := testClientID.Pick(cmd, &inputs.ClientID, cli.appPickerWithCreateOption); err != nil { |
| 332 | return nil, err |
| 333 | } |
| 334 | |
| 335 | if inputs.ClientID == newClientOption { |
| 336 | client := &management.Client{ |
| 337 | Name: auth0.String(cliLoginTestingClientName), |
| 338 | Description: auth0.String(cliLoginTestingClientDescription), |
| 339 | Callbacks: &[]string{cliLoginTestingCallbackURL}, |
| 340 | InitiateLoginURI: auth0.String(cliLoginTestingInitiateLoginURI), |
| 341 | } |
| 342 | |
| 343 | if err := cli.api.Client.Create(cmd.Context(), client); err != nil { |
| 344 | return nil, fmt.Errorf("failed to create a new client to use for testing the login: %w", err) |
| 345 | } |
| 346 | |
| 347 | inputs.ClientID = client.GetClientID() |
| 348 | |
| 349 | cli.renderer.Infof("New client created successfully.") |
| 350 | cli.renderer.Infof( |
| 351 | "If you wish to remove the created client after testing the login, run: 'auth0 apps delete %s'", |
| 352 | client.GetClientID(), |
| 353 | ) |
| 354 | cli.renderer.Newline() |
| 355 | |
| 356 | return client, nil |
| 357 | } |
| 358 | } else { |
| 359 | inputs.ClientID = args[0] |
| 360 | } |
| 361 | |
| 362 | client, err := cli.api.Client.Read(cmd.Context(), inputs.ClientID) |
| 363 | if err != nil { |
| 364 | return nil, fmt.Errorf("failed to find client with ID %q: %w", inputs.ClientID, err) |
| 365 | } |
| 366 | |
| 367 | return client, nil |
| 368 | } |
| 369 | |
| 370 | func (c *cli) customDomainPickerOptions(ctx context.Context) (pickerOptions, error) { |
| 371 | var opts pickerOptions |