We can use googleapis npm to implement google oauth2 functionality.Main thing is to create new one by refresh token when access token is expired. Get authorization code from client. Get refresh token from authorization code. Add following code to generate access token automatically when it is expired oauth2Client.on(‘tokens’, (tokens) => { if (tokens.refresh_token) { // store the refresh_token in my database! console.log(tokens.refresh_token); } console.log(tokens.access_token);});
Arbitrary reference in Mongoose schema
Supposing you need parent reference of Task schema, and parent can be either manager or developer. You don’t have to define both reference IDs in Task schema. Instead MongoDB provides feature to define arbitrary reference. You can assign value as Manager schema ID or Developer schema ID.
Set or update field automatically without manual additional in Mongoose/MongoDB
I had a chance that I need to add new field for each schema in the MongoDB. First time, I thought I should add them manually for each model definition. I investigated a better way and found that MongoDB provides plugin feature and provides hooks for each Mongoose events like find, save, update, delete. For …
Creating Reusable Components with NgTemplateOutlet in Angular
NgTemplateOutlet inserts an embedded view from a prepared TemplateRef. Using NgTemplateOutlet instead of creating specific components allows for components to be easily modified for various use cases without having to modify the component itself! The templates will be TemplateRefs using <ng-template> and the stamps will be EmbeddedViewRefs created from the TemplateRefs. EmbeddedViewRefs represent views in Angular with their own context and are the …