How to use the react-native-keychain.setInternetCredentials function in react-native-keychain

To help you get started, we’ve selected a few react-native-keychain examples, based on popular ways it is used in public projects.

github oblador / react-native-keychain / test_index.js View on Github external
accessGroup: 'accessGroup',
  authenticationPrompt: 'authenticationPrompt',
  service: 'service',
};

canImplyAuthentication(simpleOptions).then(result => {
  (result: boolean);
});

getSupportedBiometryType().then(result => {
  (result: ?string);
});

// $FlowExpectedError - First 3 arguments are required
setInternetCredentials();
setInternetCredentials('server', 'username', 'password');
setInternetCredentials('server', 'username', 'password', simpleOptions).then(
  result => {
    (result: void);
  }
);

// $FlowExpectedError - First argument is required
hasInternetCredentials();
hasInternetCredentials('server').then(result => {
  (result: boolean);
});

// $FlowExpectedError - First argument is required
getInternetCredentials();
getInternetCredentials('server', simpleOptions).then(credentials => {
  if (credentials) {
github developmentseed / observe / app / services / auth.js View on Github external
// involved (perhaps due to the way the redirect is presented?)

    const evt = await pEvent(Linking, 'url', {
      rejectionEvents: []
    })

    console.log('preauthorization completed.')

    // yes, this is deprecated since Node 11.0.0; node-url doesn't match the
    // URL constructor properly
    // https://github.com/defunctzombie/node-url/issues/37
    const { query } = url.parse(evt.url, true) // eslint-disable-line node/no-deprecated-api

    for (const key in query) {
      await Keychain.resetInternetCredentials(Config.PREAUTH_URL)
      await Keychain.setInternetCredentials(
        Config.PREAUTH_URL,
        key,
        query[key]
      )

      await CookieManager.setFromResponse(
        Config.API_URL,
        `${key}=${query[key]}`
      )
    }

    console.log('checking credentials')

    const rsp2 = await fetch(Config.API_URL + '?preauth2', {
      method: 'HEAD',
      redirect: 'error'
github developmentseed / observe / app / services / auth.js View on Github external
{
          key: requestToken,
          secret: requestTokenSecret
        }
      )
    )
  })

  const {
    oauth_token: accessToken,
    oauth_token_secret: accessTokenSecret
  } = querystring.parse(await accessTokenResponse.text())

  // update credentials
  await Keychain.resetInternetCredentials(Config.API_URL)
  await Keychain.setInternetCredentials(
    Config.API_URL,
    accessToken,
    accessTokenSecret
  )
}
github l3wi / iotaMobile / app / libs / crypto.js View on Github external
export const SaveBox = async (type, box) => {
  await Keychain.setInternetCredentials(
    type,
    box.nonce,
    box.box
  ).then(function() {
    console.log("Credentials saved successfully!");
    return true;
  });
};
github rainbow-me / rainbow / src / model / keychain.js View on Github external
export async function saveString(key, value, accessControlOptions) {
  try {
    await setInternetCredentials(key, key, value, accessControlOptions);
    console.log(`Keychain: saved string for key: ${key}`);
  } catch (err) {
    console.log(`Keychain: failed to save string for key: ${key} error: ${err}`);
  }
}
github StoDevX / AAO-React-Native / source / lib / login.js View on Github external
export function saveLoginCredentials(username: string, password: string) {
	return Keychain.setInternetCredentials(
		SIS_LOGIN_CREDENTIAL_KEY,
		username,
		password,
	).catch(() => ({}))
}
export function loadLoginCredentials(): Promise<{
github jarden-digital / react-native-pincode / src / PinCodeChoose.tsx View on Github external
endProcessConfirm = async (pinCode: string) => {
    if (pinCode === this.state.pinCode) {
      if (this.props.storePin) {
        this.props.storePin(pinCode)
      } else {
        await Keychain.setInternetCredentials(
          this.props.pinCodeKeychainName,
          this.props.pinCodeKeychainName,
          pinCode
        )
      }
      if (!!this.props.finishProcess) this.props.finishProcess(pinCode)
    } else {
      this.setState({ status: PinStatus.choose })
    }
  }
github UCSD / campus-mobile / app / util / auth.js View on Github external
storePublicAccessToken(token) {
		return Keychain
			.setInternetCredentials(publicTokenSiteName, 'publicAccessToken', token)
			.then(() => (true))
	},
github infinitered / ignite-bowser / boilerplate / app / utils / keychain.ts View on Github external
export async function save(username: string, password: string, server?: string) {
  if (server) {
    await ReactNativeKeychain.setInternetCredentials(server, username, password)
    return true
  } else {
    return ReactNativeKeychain.setGenericPassword(username, password)
  }
}