or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-2/

Google Workspace Access Authenticator

Build an authentication system that allows users to sign in with their Google account and grants access to their Google Calendar and Drive data.

Requirements

Your system should implement a Google OAuth 2.0 authentication flow with the following features:

Authentication Configuration

Configure authentication to request access to:

  • User's basic profile information
  • Google Calendar read and write access
  • Google Drive read-only access

Route Handlers

Implement three HTTP route handlers:

  1. Login Route (/auth/google): Initiates the OAuth flow with the appropriate permissions
  2. Callback Route (/auth/google/callback): Handles the OAuth callback after user authorization
  3. Profile Route (/profile): Returns the authenticated user's Google profile information and access token

Authentication Flow

  • When authentication succeeds, store the user's access token and profile data
  • The callback route should redirect to /profile on success
  • The callback route should redirect to /login-failed on failure
  • The profile route should return JSON containing the user's profile and access token

Test Cases

  • When a user visits /auth/google, they are redirected to Google's OAuth consent page @test
  • After successful authentication, the callback redirects to /profile @test
  • The profile route returns user data including access token for authenticated users @test
  • The requested scopes include calendar and drive permissions @test

Implementation

@generates

API

/**
 * Configures and returns an Express router with Google OAuth authentication routes.
 *
 * @param {Object} config - Configuration object
 * @param {string} config.clientID - Google OAuth client ID
 * @param {string} config.clientSecret - Google OAuth client secret
 * @param {string} config.callbackURL - OAuth callback URL
 * @returns {Router} Express router with authentication routes configured
 */
function createAuthRouter(config) {
  // IMPLEMENTATION HERE
}

module.exports = { createAuthRouter };

Dependencies { .dependencies }

passport { .dependency }

Provides authentication middleware for Node.js applications.

passport-google-oauth { .dependency }

Provides Google OAuth authentication support.

express { .dependency }

Provides web application routing and middleware support.