Passport-Google-Plus
Passport strategies for authenticating with the Google+ Sign-In button.
This module lets you authenticate using Google in your Node.js applications. By plugging into Passport, Google+ Sign-In can be easily and unobtrusively integrated into any application or framework that supports Connect-style middleware, including Express.
Install
$ npm install passport-google-plus
Web Server-Side Flow
Usage forImportant note
In the Google Developers Console make sure you have enabled the Google Plus API, otherwise your calls will fail (seen in this issue).
Configure Strategy
The strategy accepts a callback which is called after the user has been authenticated. The profile and OAuth credentials can be saved or mapped to a user record.
var GooglePlusStrategy = ; passport;
Configure Google+ Sign-In Button
<!-- Add where you want your sign-in button to render -->
Handle the callback & forward the authorization code
{ if authResultcode $ ; else if authResulterror console; };
Authenticate Requests
Use passport.authenticate()
, specifying the 'google'
strategy, to
authenticate requests.
For example, as route middleware in an Express application:
app;
Web Client-Side Flow
Usage forClient-side flows are also supported for web & mobile using ID tokens. When using ID tokens, profile data is limited to public information.
Configure Strategy
The strategy accepts a callback which is called after the user has been authenticated. The profile and OAuth credentials can be saved or mapped to a user record.
var GooglePlusStrategy = ; passport;
Configure Google+ Sign-In Button
<!-- Add where you want your sign-in button to render -->
Handle the callback & forward the identity token
{ if authResultcode $ ; else if authResulterror console; };