Since your frontend doesn't have the Firebase SDK, the linking process is managed by your NestJS backend. It's a standard OAuth flow where your backend orchestrates the steps.
The Flow:
- User Initiates Link: The logged-in user clicks "Link Google Account" in your Angular app.
- Backend Creates Auth URL: Your Angular app calls an endpoint on your NestJS API (e.g.,
GET /auth/google/link
). Your backend uses a library likegoogle-auth-library
to generate a unique Google authentication URL. It's crucial to include astate
parameter containing the user's session ID or a signed JWT to securely identify them upon callback. - Frontend Redirects: The NestJS API sends this URL back to the Angular app, which then redirects the user to Google's sign-in page.
- User Authenticates: The user signs in with Google and approves the permissions.