getProfile(profile) { // Normalize profile into one with {id, name, email} keys return { id: profile.id, name: profile.displayName, email: profile.emails[0].value } }
passport.use(new GoogleStrategy({ clientID: process.env.GOOGLE_AUTH_CLIENT_ID, clientSecret: process.env.GOOGLE_AUTH_CLIENT_SECRET, callbackURL: `${authURL}/auth/google/callback` }, (accessToken, refreshToken, profile, cb) => { if (profile.emails && profile.emails.find(e => e.value.match(new RegExp(`@${process.env.GOOGLE_AUTH_DOMAIN}$`)) && e.verified)) { return cb(null, profile); } return cb(`${profile.emails && profile.emails[0] && profile.emails[0].value} not within @${process.env.GOOGLE_AUTH_DOMAIN}`); }));
// Use the GoogleStrategy within Passport. // Strategies in passport require a `validate` function, which accept // credentials (in this case, an OpenID identifier and profile), and invoke a // callback with a user object. passport.use(new GoogleStrategy({ clientID: GOOGLE_ID, clientSecret: GOOGLE_SECRET, callbackURL: "http://localhost:3000/google-login-nodejs/callback" }, function (accessToken, refreshToken, profile, done) { return done(null, { name: profile.displayName, email: profile.emails[0].value }) }) )
/** Get Job */ function sampleGetJob(projectId, tenantId, jobId) { const client = new talent.JobServiceClient(); // const projectId = 'Your Google Cloud Project ID'; // const tenantId = 'Your Tenant ID (using tenancy is optional)'; // const jobId = 'Job ID'; const formattedName = client.jobPath(projectId, tenantId, jobId); client.getJob({name: formattedName}) .then(responses => { const response = responses[0]; console.log(`Job name: ${response.name}`); console.log(`Requisition ID: ${response.requisitionId}`); console.log(`Title: ${response.title}`); console.log(`Description: ${response.description}`); console.log(`Posting language: ${response.languageCode}`); for (const address of response.addresses) { console.log(`Address: ${address}`); } for (const email of response.applicationInfo.emails) { console.log(`Email: ${email}`); } for (const websiteUri of response.applicationInfo.uris) { console.log(`Website: ${websiteUri}`); } }) .catch(err => { console.error(err); }); }