MCPcopy Create free account
hub / github.com/auth0/auth0-cli / createAPICmd

Function createAPICmd

internal/cli/apis.go:242–373  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

240}
241
242func createAPICmd(cli *cli) *cobra.Command {
243 var inputs struct {
244 Name string
245 Identifier string
246 Scopes []string
247 TokenLifetime int
248 AllowOfflineAccess bool
249 SigningAlgorithm string
250 SubjectTypeAuthorization string
251 EnforcePolicies bool
252 TokenDialect string
253 }
254
255 cmd := &cobra.Command{
256 Use: "create",
257 Args: cobra.NoArgs,
258 Short: "Create a new API",
259 Long: "Create a new API.\n\n" +
260 "To create interactively, use `auth0 apis create` with no flags.\n\n" +
261 "To create non-interactively, supply the name, identifier, scopes, " +
262 "token lifetime and whether to allow offline access through the flags.",
263 Example: ` auth0 apis create
264 auth0 apis create --name myapi
265 auth0 apis create --name myapi --identifier http://my-api
266 auth0 apis create --name myapi --identifier http://my-api --token-lifetime 6100
267 auth0 apis create --name myapi --identifier http://my-api --token-lifetime 6100 --offline-access=true
268 auth0 apis create --name myapi --identifier http://my-api --token-lifetime 6100 --offline-access=false --scopes "letter:write,letter:read"
269 auth0 apis create --name myapi --identifier http://my-api --token-lifetime 6100 --offline-access=false --scopes "letter:write,letter:read" --signing-alg "RS256"
270 auth0 apis create -n myapi -i http://my-api -t 6100 -o false -s "letter:write,letter:read" --signing-alg "RS256" --json
271 auth0 apis create -n myapi -i http://my-api -t 6100 -o false -s "letter:write,letter:read" --signing-alg "RS256" --json-compact
272 auth0 apis create --name myapi --identifier http://my-api --subject-type-authorization '{"user":{"policy":"allow_all"},"client":{"policy":"deny_all"}}'
273 auth0 apis create --name myapi --identifier http://my-api --enforce-policies --token-dialect access_token_authz`,
274 RunE: func(cmd *cobra.Command, args []string) error {
275 if err := apiName.Ask(cmd, &inputs.Name, nil); err != nil {
276 return err
277 }
278
279 if err := apiIdentifier.Ask(cmd, &inputs.Identifier, nil); err != nil {
280 return err
281 }
282
283 if err := apiScopes.AskMany(cmd, &inputs.Scopes, nil); err != nil {
284 return err
285 }
286
287 defaultTokenLifetime := strconv.Itoa(apiDefaultTokenLifetime)
288 if err := apiTokenLifetime.Ask(cmd, &inputs.TokenLifetime, &defaultTokenLifetime); err != nil {
289 return err
290 }
291
292 if err := apiOfflineAccess.AskBool(cmd, &inputs.AllowOfflineAccess, nil); err != nil {
293 return err
294 }
295
296 if err := apiSigningAlgorithm.Ask(cmd, &inputs.SigningAlgorithm, auth0.String("RS256")); err != nil {
297 return err
298 }
299

Callers 1

apisCmdFunction · 0.85

Calls 13

WaitingFunction · 0.92
apiScopesForFunction · 0.85
AskManyMethod · 0.80
AskBoolMethod · 0.80
ErrorfMethod · 0.80
SelectMethod · 0.80
APICreateMethod · 0.80
RegisterStringMethod · 0.80
RegisterStringSliceMethod · 0.80
RegisterBoolMethod · 0.80
RegisterIntMethod · 0.80
CreateMethod · 0.65

Tested by

no test coverage detected