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

# TypeScript typings for Identity Toolkit API v2

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-v2 --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=v2',
  () => {
    // 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', 'v2', () => {
  // 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
/*
Revokes a user's token from an Identity Provider (IdP). This is done by manually providing an IdP credential, and the token types for revocation. 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.revokeToken({});

/*
List all default supported Idps.
*/
await gapi.client.identitytoolkit.defaultSupportedIdps.list({});

/*
Retrieve an Identity Toolkit project configuration.
*/
await gapi.client.identitytoolkit.projects.getConfig({name: 'name'});

/*
Update an Identity Toolkit project configuration.
*/
await gapi.client.identitytoolkit.projects.updateConfig({name: 'name'});

/*
Gets password policy config set on the project or tenant.
*/
await gapi.client.identitytoolkit.getPasswordPolicy({});

/*
Gets parameters needed for reCAPTCHA analysis.
*/
await gapi.client.identitytoolkit.getRecaptchaConfig({});
```

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