Skip to content

getGenericPassword() ​

ts
function getGenericPassword(options?): Promise<false | UserCredentials>

Fetches the username and password combination for the given service.

Parameters ​

• options?: GetOptions

A keychain options object.

Returns ​

Promise<false | UserCredentials>

Resolves to an object containing service, username, password, and storage when credentials are found, or false when no credentials exist for the requested service. Keychain access errors reject the promise.

Example ​

typescript
const credentials = await Keychain.getGenericPassword();
if (credentials) {
  console.log('Credentials successfully loaded for user ' + credentials.username);
} else {
  console.log('No credentials stored');
}

Defined in ​

index.ts:71