createQuickstartApp creates an Auth0 application client for the given quickstart config key, writes the env config file, and prints setup guidance. It returns the newly created client ID.
(cmd *cobra.Command, cli *cli, inputs SetupInputs, qsConfigKey string)
| 1049 | // createQuickstartApp creates an Auth0 application client for the given quickstart config key, |
| 1050 | // writes the env config file, and prints setup guidance. It returns the newly created client ID. |
| 1051 | func createQuickstartApp(cmd *cobra.Command, cli *cli, inputs SetupInputs, qsConfigKey string) (string, error) { |
| 1052 | config, exists := auth0.QuickstartConfigs[qsConfigKey] |
| 1053 | if !exists { |
| 1054 | return "", fmt.Errorf("unsupported quickstart arguments: %s. Supported types: %v", qsConfigKey, getSupportedQuickstartTypes()) |
| 1055 | } |
| 1056 | |
| 1057 | expoScheme := readExpoScheme(inputs.Framework) |
| 1058 | nativeBundleID := resolveNativeBundleID(inputs) |
| 1059 | |
| 1060 | // For dotnet-mobile/MAUI, register the custom URI scheme callback. |
| 1061 | if (inputs.Framework == "dotnet-mobile" || inputs.Framework == "maui") && nativeBundleID != "" { |
| 1062 | config.RequestParams.Callbacks = []string{nativeBundleID + "://callback"} |
| 1063 | } |
| 1064 | |
| 1065 | client, err := generateClient(inputs, config.RequestParams) |
| 1066 | if err != nil { |
| 1067 | return "", fmt.Errorf("failed to generate client: %w", err) |
| 1068 | } |
| 1069 | |
| 1070 | if err := ansi.Waiting(func() error { |
| 1071 | return cli.api.Client.Create(cmd.Context(), client) |
| 1072 | }); err != nil { |
| 1073 | return "", fmt.Errorf("failed to create application: %w", err) |
| 1074 | } |
| 1075 | |
| 1076 | // Inject the audience variable when an API is also being created. |
| 1077 | envValues := config.EnvValues |
| 1078 | if inputs.API && inputs.Identifier != "" && config.AudienceVar != "" { |
| 1079 | envValues = make(map[string]string, len(config.EnvValues)+1) |
| 1080 | for k, v := range config.EnvValues { |
| 1081 | envValues[k] = v |
| 1082 | } |
| 1083 | envValues[config.AudienceVar] = inputs.Identifier |
| 1084 | } |
| 1085 | |
| 1086 | resolvedEnv, err := replaceDetectionSub(envValues, cli.tenant, client, inputs.Port) |
| 1087 | if err != nil { |
| 1088 | return "", err |
| 1089 | } |
| 1090 | |
| 1091 | if err := cli.WriteQuickstartConfig(cmd, resolvedEnv, &config.Strategy); err != nil { |
| 1092 | return "", fmt.Errorf("failed to generate config file: %w", err) |
| 1093 | } |
| 1094 | |
| 1095 | printClientDetails(cli, client) |
| 1096 | printNativeGuidance(cli, inputs.Framework, expoScheme, nativeBundleID) |
| 1097 | |
| 1098 | return client.GetClientID(), nil |
| 1099 | } |
| 1100 | |
| 1101 | // readExpoScheme reads the "expo.scheme" field from app.json in the working directory. |
| 1102 | // Returns the raw string value, or empty if the framework is not expo or the file is missing. |