# OAuth Setup Notes

## Required Package Installation

The OAuth implementation requires **Laravel Socialite** to be installed:

```bash
composer require laravel/socialite
```

## Environment Configuration

Add the following to your `.env` file:

```env
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_REDIRECT_URI=https://research-api.zentiaai.com/public/api/auth/google/callback

# LinkedIn OAuth
LINKEDIN_CLIENT_ID=your_linkedin_client_id
LINKEDIN_CLIENT_SECRET=your_linkedin_client_secret
LINKEDIN_REDIRECT_URI=https://research-api.zentiaai.com/public/api/auth/linkedin/callback
```

## Config File Setup

Update `config/services.php`:

```php
'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => env('GOOGLE_REDIRECT_URI'),
],

'linkedin' => [
    'client_id' => env('LINKEDIN_CLIENT_ID'),
    'client_secret' => env('LINKEDIN_CLIENT_SECRET'),
    'redirect' => env('LINKEDIN_REDIRECT_URI'),
],
```

## OAuth Provider Setup

### Google OAuth
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select existing
3. Enable Google+ API
4. Create OAuth 2.0 credentials
5. Add authorized redirect URIs

### LinkedIn OAuth
1. Go to [LinkedIn Developers](https://www.linkedin.com/developers/)
2. Create a new app
3. Add redirect URLs
4. Get Client ID and Client Secret

## Database Migration

Run the migration:
```bash
php artisan migrate
```

## Testing

Test the endpoints:
- `GET /api/auth/google/redirect?action=login&redirect_uri=https://frontend.com/callback`
- `POST /api/auth/google/callback` (with code and state)
- `POST /api/auth/google/unlink` (authenticated)

