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

Method pickOrganizationForGrantIfRequired

internal/cli/test.go:487–509  ·  view source on GitHub ↗

pickOrganizationForGrantIfRequired checks if the client grant for the given audience requires an organization. If it does and no organization has been specified, it either fails with a descriptive error (if no organizations exist on the tenant) or opens an interactive picker to let the user select o

(cmd *cobra.Command, client *management.Client, audience string, organization *string)

Source from the content-addressed store, hash-verified

485// specified, it either fails with a descriptive error (if no organizations exist
486// on the tenant) or opens an interactive picker to let the user select one.
487func (c *cli) pickOrganizationForGrantIfRequired(cmd *cobra.Command, client *management.Client, audience string, organization *string) error {
488 if *organization != "" {
489 return nil
490 }
491
492 var list *management.ClientGrantList
493 if err := ansi.Waiting(func() (err error) {
494 list, err = c.api.ClientGrant.List(
495 cmd.Context(),
496 management.Parameter("audience", audience),
497 management.Parameter("client_id", client.GetClientID()),
498 )
499 return err
500 }); err != nil {
501 return err
502 }
503
504 if len(list.ClientGrants) == 0 || list.ClientGrants[0].GetOrganizationUsage() != "require" {
505 return nil
506 }
507
508 return testOrganization.Pick(cmd, organization, c.organizationPickerOptionsForGrant(audience))
509}
510
511func (c *cli) organizationPickerOptionsForGrant(audience string) pickerOptionsFunc {
512 return func(ctx context.Context) (pickerOptions, error) {

Callers 1

testTokenCmdFunction · 0.80

Calls 4

WaitingFunction · 0.92
ListMethod · 0.65
PickMethod · 0.45

Tested by

no test coverage detected