# Initial Setup Instructions

## Step 1: Run the Setup Script

Since you only have your Client ID and Client Secret, you need to authorize the application first.

```bash
php setup.php
```

## Step 2: Follow the Authorization Flow

The script will:
1. Display a URL like: `https://www.upwork.com/ab/account-security/oauth2/authorize?client_id=...`
2. Copy and paste this URL into your browser
3. Log in to your Upwork account if needed
4. Click "Authorize" to grant permissions
5. You'll be redirected to your redirect URI with a code parameter
6. Copy the code from the URL (the part after `?code=`)
7. Paste it back into the terminal when prompted

## Step 3: Tokens Saved

After successful authorization:
- Your `tokens.json` file will be created with:
  - access_token
  - refresh_token
  - expires_in (unix timestamp)

## Step 4: Run Your Main Application

Now you can run your main application:

```bash
php myapp.php
```

The application will:
- Load tokens from `tokens.json`
- Automatically refresh them when they expire
- Save the refreshed tokens back to the file
- Continue working indefinitely without manual intervention

## Troubleshooting

**If you see "ERROR: tokens.json not found"**
- Run `php setup.php` first

**If authorization fails**
- Make sure your Client ID and Secret are correct
- Verify your redirect URI matches what's configured in Upwork Developer Portal
- Check that your Upwork account has API access enabled

**If you need to re-authorize**
- Delete `tokens.json`
- Run `php setup.php` again

