npm package: @maxim_mazurok/gapi.client.identitytoolkit-v1
Description: TypeScript typings for Identity Toolkit API v1
Author: Maxim Mazurok
Latest version: 0.1.20260311

# TypeScript typings for Identity Toolkit API v1

The Google Identity Toolkit API lets you use open standards to verify a user's identity.
For detailed description please check [documentation](https://cloud.google.com/identity-platform).

## Installing

Install typings for Identity Toolkit API:

```
npm install @types/gapi.client.identitytoolkit-v1 --save-dev
```

## Usage

You need to initialize Google API client in your code:

```typescript
gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});
```

Then load api client wrapper:

```typescript
gapi.client.load(
  'https://identitytoolkit.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.identitytoolkit
  },
);
```

```typescript
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('identitytoolkit', 'v1', () => {
  // now we can use:
  // gapi.client.identitytoolkit
});
```

Don't forget to authenticate your client before sending any request to resources:

```typescript
// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [
    // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
    'https://www.googleapis.com/auth/cloud-platform',

    // View and administer all your Firebase data and settings
    'https://www.googleapis.com/auth/firebase',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  },
);
```

After that you can use Identity Toolkit API resources: <!-- TODO: make this work for multiple namespaces -->

```typescript
/*
If an email identifier is specified, checks and returns if any user account is registered with the email. If there is a registered account, fetches all providers associated with the account's email. If [email enumeration protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, this method returns an empty list. If the provider ID of an Identity Provider (IdP) is specified, creates an authorization URI for the IdP. The user can be directed to this URI to sign in with the IdP. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.createAuthUri({});

/*
Deletes a user's account.
*/
await gapi.client.identitytoolkit.accounts.delete({});

/*
Experimental
*/
await gapi.client.identitytoolkit.accounts.issueSamlResponse({});

/*
Gets account information for all matched accounts. For an end user request, retrieves the account of the end user. For an admin request with Google OAuth 2.0 credential, retrieves one or multiple account(s) with matching criteria.
*/
await gapi.client.identitytoolkit.accounts.lookup({});

/*
Resets the password of an account either using an out-of-band code generated by sendOobCode or by specifying the email and password of the account to be modified. Can also check the purpose of an out-of-band code without consuming it.
*/
await gapi.client.identitytoolkit.accounts.resetPassword({});

/*
Sends an out-of-band confirmation code for an account. Requests from a authenticated request can optionally return a link including the OOB code instead of sending it.
*/
await gapi.client.identitytoolkit.accounts.sendOobCode({});

/*
Sends a SMS verification code for phone number sign-in. To localize the text of the SMS sent to the user, set the HTTP header `X-Firebase-Locale` to the language code that corresponds with the user's locale. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.sendVerificationCode({});

/*
Signs in or signs up a user by exchanging a custom Auth token. Upon a successful sign-in or sign-up, a new Identity Platform ID token and refresh token are issued for the user. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.signInWithCustomToken({});

/*
Signs in or signs up a user with a out-of-band code from an email link. If a user does not exist with the given email address, a user record will be created. If the sign-in succeeds, an Identity Platform ID and refresh token are issued for the authenticated user. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.signInWithEmailLink({});

/*
Signs in or signs up a user with iOS Game Center credentials. If the sign-in succeeds, a new Identity Platform ID token and refresh token are issued for the authenticated user. The bundle ID is required in the request header as `x-ios-bundle-identifier`. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project. Apple has [deprecated the `playerID` field](https://developer.apple.com/documentation/gamekit/gkplayer/1521127-playerid/). The Apple platform Firebase SDK will use `gamePlayerID` and `teamPlayerID` from version 10.5.0 and onwards. Upgrading to SDK version 10.5.0 or later updates existing integrations that use `playerID` to instead use `gamePlayerID` and `teamPlayerID`. When making calls to `signInWithGameCenter`, you must include `playerID` along with the new fields `gamePlayerID` and `teamPlayerID` to successfully identify all existing users. Upgrading existing Game Center sign in integrations to SDK version 10.5.0 or later is irreversible.
*/
await gapi.client.identitytoolkit.accounts.signInWithGameCenter({});

/*
Signs in or signs up a user using credentials from an Identity Provider (IdP). This is done by manually providing an IdP credential, or by providing the authorization response obtained via the authorization request from CreateAuthUri. If the sign-in succeeds, a new Identity Platform ID token and refresh token are issued for the authenticated user. A new Identity Platform user account will be created if the user has not previously signed in to the IdP with the same account. In addition, when the "One account per email address" setting is enabled, there should not be an existing Identity Platform user account with the same email address for a new user account to be created. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.signInWithIdp({});

/*
Signs in a user with email and password. If the sign-in succeeds, a new Identity Platform ID token and refresh token are issued for the authenticated user. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.signInWithPassword({});

/*
Completes a phone number authentication attempt. If a user already exists with the given phone number, an ID token is minted for that user. Otherwise, a new user is created and associated with the phone number. This method may also be used to link a phone number to an existing user. To localize the text of the SMS sent to the user, set the HTTP header `X-Firebase-Locale` to the language code that corresponds with the user's locale. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.signInWithPhoneNumber({});

/*
Signs up a new email and password user or anonymous user, or upgrades an anonymous user to email and password. For an admin request with a Google OAuth 2.0 credential with the proper [permissions](https://cloud.google.com/identity-platform/docs/access-control), creates a new anonymous, email and password, or phone number user. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.signUp({});

/*
Updates account-related information for the specified user by setting specific fields or applying action codes. Requests from administrators and end users are supported.
*/
await gapi.client.identitytoolkit.accounts.update({});

/*
Verifies an iOS client is a real iOS device. If the request is valid, a receipt will be sent in the response and a secret will be sent via Apple Push Notification Service. The client should send both of them back to certain Identity Platform APIs in a later call (for example, /accounts:sendVerificationCode), in order to verify the client. The bundle ID is required in the request header as `x-ios-bundle-identifier`. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.accounts.verifyIosClient({});

/*
Signs up a new email and password user or anonymous user, or upgrades an anonymous user to email and password. For an admin request with a Google OAuth 2.0 credential with the proper [permissions](https://cloud.google.com/identity-platform/docs/access-control), creates a new anonymous, email and password, or phone number user. An [API key](https://cloud.google.com/docs/authentication/api-keys) is required in the request in order to identify the Google Cloud project.
*/
await gapi.client.identitytoolkit.projects.accounts({
  targetProjectId: 'targetProjectId',
});

/*
Creates a session cookie for the given Identity Platform ID token. The session cookie is used by the client to preserve the user's login state.
*/
await gapi.client.identitytoolkit.projects.createSessionCookie({
  targetProjectId: 'targetProjectId',
});

/*
Looks up user accounts within a project or a tenant based on conditions in the request.
*/
await gapi.client.identitytoolkit.projects.queryAccounts({
  targetProjectId: 'targetProjectId',
});

/*
Gets a project's public Identity Toolkit configuration. (Legacy) This method also supports authenticated calls from a developer to retrieve non-public configuration.
*/
await gapi.client.identitytoolkit.getProjects({});

/*
Retrieves public keys of the legacy Identity Toolkit token signer to enable third parties to verify the legacy ID token. For now the X509 pem cert is the only format supported.
*/
await gapi.client.identitytoolkit.getPublicKeys({});

/*
Gets parameters needed for generating a reCAPTCHA challenge.
*/
await gapi.client.identitytoolkit.getRecaptchaParams({});

/*
Retrieves the set of public keys of the session cookie JSON Web Token (JWT) signer that can be used to validate the session cookie created through createSessionCookie.
*/
await gapi.client.identitytoolkit.getSessionCookiePublicKeys({});
```

For provenance information see [Provenance section on NPM](https://www.npmjs.com/package/@maxim_mazurok/gapi.client.identitytoolkit-v1#Provenance:~:text=none-,Provenance,-Built%20and%20signed)