Skip to content

Instantly share code, notes, and snippets.

@mfrancois3k
Forked from ancyrweb/generate-id-token.ts
Created December 22, 2022 21:37
Show Gist options
  • Select an option

  • Save mfrancois3k/e89b165aa4502cc149ddd2d4ad912558 to your computer and use it in GitHub Desktop.

Select an option

Save mfrancois3k/e89b165aa4502cc149ddd2d4ad912558 to your computer and use it in GitHub Desktop.
Api Token
async generateIDToken(uid: string) {
const customToken = await this.admin.auth().createCustomToken(uid);
const res = await rp({
url: `https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken?key=${this.apikey}`,
method: 'POST',
body: {
token: customToken,
returnSecureToken: true,
},
json: true,
});
return {
token: res.idToken,
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment