Registers a Hapi server method to retrieve Google oAuth2 certificates for validation of ID tokens. Since certificates do not change frequently, they are cached using Hapi's native cache for 24 hours to eliminate unnecessary network calls.
server.register({ register: require('hapi-google-oauth2-certs') }, function (err) {
if (err) {
console.error('Failed to load plugin:', err);
}
});
server.methods.auth.google.getCertificate('someCertificateId', function (err, certificate) {
if (err) {
// Handle error
}
// Use certificate
});