Type alias AuthFailureCallback

AuthFailureCallback: ((url: string, auth: Auth) => Auth | void | Promise<Auth | void>)

Type declaration

    • (url: string, auth: Auth): Auth | void | Promise<Auth | void>
    • The callback is called when credentials fail. This is helpful to know if you were using a saved password in the AuthCallback, then you may want to offer the user the option to delete the currently saved password. It also gives you an opportunity to retry the request with new credentials.

      As long as the callback function returns credentials, it will keep trying. This is the main reason we don't re-use the AuthCallback for this purpose. If we did, then a naive AuthCallback that simply returned saved credentials might loop indefinitely.

      Example

      await clone({
      ...,
      onAuthFailure: (url, auth) => {
      forgetSavedPassword(url)
      if (confirm('Access was denied. Try again?')) {
      auth = {
      username: prompt('Enter username'),
      password: prompt('Enter password'),
      }
      return auth
      } else {
      return { cancel: true }
      }
      }
      })

      Parameters

      • url: string
      • auth: Auth

      Returns Auth | void | Promise<Auth | void>

Generated using TypeDoc