intro Help

Authorization via Google e-mail

Also, the user must be able to sign in/sign up using Google auth. In the classic auth we know, that we need to check, that user's e-mail is exist and the e-mail really belongs to the user, but in this situation, Google auth handle these tasks, so we do not need to do it ourselves.

Registration flow

  1. The user clicks the Google button

  2. The modal window by google with e-mails is shown. The user chooses e-mail

  3. If account with this e-mail is already exists, we need to show info about it

  4. Otherwise, the account is creating and we redirect user to dashboard page

Login flow

  1. The user clicks the Google button

  2. The modal window by google with e-mails is shown. The user chooses e-mail

  3. If account with this e-mail does not exist, we need to show info about it

  4. Otherwise, we redirect user to dashboard page

Info for devs - auth types (req/res)

Types for registration and login are similar, so:

GET /api/user/google HTTP/1.1 Host: example.com Authorization: Bearer abc123xyz1-google-jwt...

If this is registration

HTTP/1.1 201 Created Date: Wed, 08 Jan 2025 12:00:00 GMT

If this is logining

HTTP/1.1 200 Success Date: Wed, 08 Jan 2025 12:00:00 GMT

export type AuthViaGoogleResponse = { accessToken: string; refreshToken: string; }

Explanation: the frontend does auth via Google API and gets google-jwt. Then frontend sends HTTP GET request to the backend, backend decodes google-jwt and extracts info from payload
The email, name, picture, given_name, family_name fields are needs for auth.

Last modified: 13 January 2025