MCPcopy Create free account
hub / github.com/algolia/cli / callWithReauth

Function callWithReauth

pkg/cmd/application/create/create.go:469–493  ·  view source on GitHub ↗

callWithReauth runs fn, re-authenticating once and retrying on an expired session.

(
	io *iostreams.IOStreams,
	client *dashboard.Client,
	token *string,
	label string,
	fn func(token string) error,
)

Source from the content-addressed store, hash-verified

467
468// callWithReauth runs fn, re-authenticating once and retrying on an expired session.
469func callWithReauth(
470 io *iostreams.IOStreams,
471 client *dashboard.Client,
472 token *string,
473 label string,
474 fn func(token string) error,
475) error {
476 io.StartProgressIndicatorWithLabel(label)
477 err := fn(*token)
478 io.StopProgressIndicator()
479 if err == nil {
480 return nil
481 }
482
483 newToken, reAuthErr := auth.ReauthenticateIfExpired(io, client, err)
484 if reAuthErr != nil {
485 return reAuthErr
486 }
487 *token = newToken
488
489 io.StartProgressIndicatorWithLabel(label)
490 err = fn(*token)
491 io.StopProgressIndicator()
492 return err
493}

Callers 1

createApplicationFunction · 0.70

Calls 3

ReauthenticateIfExpiredFunction · 0.92
StopProgressIndicatorMethod · 0.80

Tested by

no test coverage detected