0.0.1 • Published 9 years ago

hapi-google-oauth2-certs v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

Build Status npm version

Introduction

Registers a Hapi server method to retrieve Google oAuth2 certificates for validation of ID tokens. Since certificates do not change regularly, they are cached using Hapi's native cache for 24 hours to eliminate unnecessary network calls.

Usage

Register this plugin:

server.register({ register: require('hapi-google-oauth2-certs') }, function (err) {
    if (err) {
        console.error('Failed to load plugin:', err);
    }
});

Retrieve a certificate:

server.methods.auth.google.getCertificate('someCertificateId', function (err, certificate) {
    if (err) {
        // Handle error
    }
    
    // Use certificate
});