Store Google authenticated users into a custom

Continuing the discussion from How to Store Google authenticated users into a custom database?:

I want to add all users to my MongoDB custom database upon signup.
Can you provide an example of how to write the post-login script? which API should I call?