or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-10/

Legacy Google Authentication Service

Build a user authentication service that supports legacy Google OAuth 1.0a authentication for an existing application that needs to maintain backwards compatibility.

Requirements

Your service must:

  1. Initialize and configure a legacy Google authentication strategy with consumer credentials and a callback endpoint
  2. Provide an authentication route that initiates the OAuth flow
  3. Handle the OAuth callback to complete authentication and retrieve user information
  4. Extract and store the authentication token and token secret for the authenticated user
  5. Retrieve the user's profile information including their unique identifier and display name

Capabilities

Authentication Strategy Setup

  • The strategy is configured with consumerKey, consumerSecret, and callbackURL @test
  • The verify callback receives token, tokenSecret, profile, and done parameters @test

Authentication Flow

  • The authentication route redirects to Google's OAuth 1.0a authorization endpoint @test
  • The callback route processes the OAuth response and completes authentication @test

User Profile Extraction

  • The user's Google ID is extracted from the profile @test
  • The user's display name is extracted from the profile @test

Implementation

@generates

API

/**
 * Configures and returns a Passport.js instance with Google OAuth 1.0a strategy
 *
 * @param {Object} config - Configuration object
 * @param {string} config.consumerKey - Google OAuth 1.0a consumer key
 * @param {string} config.consumerSecret - Google OAuth 1.0a consumer secret
 * @param {string} config.callbackURL - OAuth callback URL
 * @param {Function} config.verifyCallback - Function to handle verified user (token, tokenSecret, profile, done) => void
 * @returns {Object} Configured Passport instance
 */
function setupGoogleAuth(config) {
  // IMPLEMENTATION HERE
}

/**
 * Extracts user information from the OAuth profile
 *
 * @param {Object} profile - Google user profile from OAuth
 * @returns {Object} User object with id and displayName properties
 */
function extractUserInfo(profile) {
  // IMPLEMENTATION HERE
}

module.exports = {
  setupGoogleAuth,
  extractUserInfo,
};

Dependencies { .dependencies }

passport-google-oauth { .dependency }

Provides Google OAuth 1.0a authentication strategy for Passport.js

passport { .dependency }

Authentication middleware framework for Node.js