arrow_back
Back to Tickets
Edit Trouble Ticket
Update the ticket information below
Date Initiated
*
Status
*
Open
Pending
Completed
Terminated
Creator
*
Marcus
Priority
*
1
Urgent
Select urgency...
Urgent
Not Urgent
Important
Select importance...
Important
Not Important
Project Name
*
zfrika
Problem
*
install "Use Social Login Instead of Email (Highest Conversion of All)**" get 50-80% conversion.
Question
how do you create a new user in your database? where is he saved?
Root Cause
Notes
objects from OAuth: Field Data Type How to access ----------------------- ID String profile.id (Google's unique ID for the user) Display Name String profile.displayName (e.g., "John Doe") Emails Array of Objects profile.emails[0].value (The primary email) Photos Array of Objects profile.photos[0].value (URL to their profile pic) Raw JSON Object profile._json (The exact raw response from Google) name: 'Marcus Kironyo (String #242)', given_name: 'Marcus', family_name: 'Kironyo', picture: 'https://lh3.googleusercontent.com/a/ACg8ocI55NawlMPyFG3fhoyMkXbZUvKFiB7nUj-qietNWTg5qzL6Av04=s96-c', email: 'kkironyo@gmail.com',
Strategy
Helpful People
Helpful Links
Diagram
Previous Steps
1client id and client secret were defined. now update client side now update nodejs 2updated and got an error Access blocked: authorization error. invalid request. 3resolved issue in defining Go to: Google Cloud Console -> APIs & Services -> Credentials. Check your OAuth 2.0 Client ID: Look at the Authorized redirect URIs section. The Fix: Ensure the URL there matches your code exactly. If your code uses https://example.com/auth/google/callback, the console must have that exact string. Note: Google no longer allows "localhost" without a port or plain IP addresses for production. Use http://127.0.0.1:3000 (or your specific port) if testing locally. 4 got this returned GET /auth/google/callback?code=4%2F0ASc3gC2nw6fqd70YQylX6a0Q5ejrpDkUn6IwY53HNVzWBqvhg1BHTzmDhA2Mr_kBpoSPVw&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+openid&authuser=0&prompt=consent 404 2.011 ms - 3084 1moving to production resolve date issue. http is not supported by authentication. 2you need to sign up the user when google auth works 4create and add an object const token = require('crypto').randomBytes(32).toString('hex'); const userdata = new collection(data); userdata.confirmationToken = token; userdata.confirmationExpires = Date.now(); await userdata.save(); add a google parameter that confirms if we used google to signup. if so, then let the user use the google sessionID to access data.
Next Steps
now with the profile pictures, I can create contacts easily with images.
Solution
accomplished: Google OAuth handshake ✅ Profile received ✅ Email verified ✅ Session ID created ✅ if the user email already exist, the direct the user to login page. if the email does not exist, then add the user name the database. then direct them to login page. and assign them the datatoken. 3check for duplicate email. test if delete and creat a new email with normal login update the front interface to give the use the option to chose either. add missing data to profile in database if the account exist. signing and check if any of the datafields are empty. update them with data from the OAuth. case : if user signing with one email method but wants to use the other. allow them to use the same email. update development with changes that were made in production. model/user. controller/zfrikaprod view/newpost/login.ejs
Insight
Date Resolved
save
Update Ticket
Cancel