function getLoginMethodAndParams(firebase, credentials) {
  const {
    email,
    password,
    provider,
    type,
    token,
    scopes,
    phoneNumber,
    applicationVerifier,
    credential,
    emailLink
  } = credentials
  // Credential Auth
  if (credential) {
    // Attempt to use signInAndRetrieveDataWithCredential if it exists (see #467 for more info)
    const credentialAuth = firebase.auth().signInAndRetrieveDataWithCredential

    if (credentialAuth) {
      return {
        method: 'signInAndRetrieveDataWithCredential',
        params: [credential]
      }
    }
    return { method: 'signInWithCredential', params: [credential] }
  }

  // Provider Auth
  if (provider) {
    // Verify providerName is valid
    if (supportedAuthProviders.indexOf(provider.toLowerCase()) === -1) {
      throw new Error(`${provider} is not a valid Auth Provider`)
    }
    if (token) {
      throw new Error(
        'provider with token no longer supported, use credential parameter instead'
      )
    }
    const authProvider = createAuthProvider(firebase, provider, scopes)
    if (type === 'popup') {
      return { method: 'signInWithPopup', params: [authProvider] }
    }
    return { method: 'signInWithRedirect', params: [authProvider] }
  }

  // Token Auth
  if (token) {
    // Check for new sign in method (see #484 for more info)
    const tokenAuth = firebase.auth().signInAndRetrieveDataWithCustomToken

    if (tokenAuth) {
      return { method: 'signInAndRetrieveDataWithCustomToken', params: [token] }
    }

    return { method: 'signInWithCustomToken', params: [token] }
  }

  // Phone Number Auth
  if (phoneNumber) {
    if (!applicationVerifier) {
      throw new Error(
        'Application verifier is required for phone authentication'
      )
    }
    return {
      method: 'signInWithPhoneNumber',
      params: [phoneNumber, applicationVerifier]
    }
  }

  // Passwordless sign-in
  if (emailLink && email) {
    return { method: 'signInWithEmailLink', params: [email, emailLink] }
  }

  // Check for new sign in method (see #484 for more info)
  // Note: usage of signInAndRetrieveDataWithEmailAndPassword is now a fallback since it is deprecated (see #484 for more info)
  if (!firebase.auth().signInWithEmailAndPassword) {
    return {
      method: 'signInAndRetrieveDataWithEmailAndPassword',
      params: [email, password]
    }
  }

  // Email/Password Auth
  return { method: 'signInWithEmailAndPassword', params: [email, password] }
}
Get correct login method and params order based on provided
credentials
@param {object} firebase - Internal firebase object
@param {object} credentials - Login credentials
@param {string} credentials.email - Email to login with (only needed for
email login)
@param {string} credentials.password - Password to login with (only needed
for email login)
@param {string} credentials.provider - Provider name such as google, twitter
(only needed for 3rd party provider login)
@param {string} credentials.type - Popup or redirect (only needed for 3rd
party provider login)
@param {string} credentials.token - Custom or provider token
@param {firebase.auth.AuthCredential} credentials.credential - Custom or
provider token
@param {Array|string} credentials.scopes - Scopes to add to provider
(i.e. email)
@returns {object} Method and params for calling login
@private