Skip to content

Instantly share code, notes, and snippets.

@skibaalex
Forked from shangyilim/verify-sms-code-express.js
Last active September 5, 2020 19:36
Show Gist options
  • Save skibaalex/b0755062f1ac128ba627ec7ab31a2436 to your computer and use it in GitHub Desktop.
Save skibaalex/b0755062f1ac128ba627ec7ab31a2436 to your computer and use it in GitHub Desktop.
import { google } from 'googleapis';
app.post('/verifyCode', function (req, res) {
const { smsCodem, sessionIdentifier } = req.body;
const identityToolkit = google.identitytoolkit({
auth: 'GCP_API_KEY',
version: 'v3',
});
//sessionIdentifier comes from when we send the sms message
const phoneSessionId = getPhoneSessio(sessionIdentifie)
await identityToolkit.relyingparty.verifyPhoneNumber({
code: verificationCode,
sessionInfo: phoneSessionId,
});
// verification code accepted, update phoneNumberVerified flag in database
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment