> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vibehub.co.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Sign in and manage your VibeHub CLI credentials

## Overview

Before using the VibeHub CLI, you need to authenticate with your VibeHub account. Authentication uses OAuth through your browser for security.

## Signing In

### Basic Login

```bash theme={null}
vibe login
```

This command:

1. Opens your default browser
2. Directs you to VibeHub's login page
3. After signing in, returns you to the terminal
4. Stores your credentials locally

### Login with Profile

If you use multiple accounts, specify a profile:

```bash theme={null}
vibe login --profile work
vibe login --profile personal
```

## How Authentication Works

When you run `vibe login`:

```mermaid theme={null}
sequenceDiagram
    participant CLI
    participant Browser
    participant VibeHub
    CLI->>Browser: Open login URL
    Browser->>VibeHub: User signs in
    VibeHub->>Browser: Redirect with token
    Browser->>CLI: Token received
    CLI->>CLI: Store token locally
```

1. The CLI opens your browser to VibeHub
2. You sign in with Google (or your existing session)
3. VibeHub generates an authentication token
4. The token is securely stored on your machine

## Credential Storage

Your credentials are stored in:

| OS      | Location                             |
| ------- | ------------------------------------ |
| macOS   | `~/.vibehub/credentials`             |
| Linux   | `~/.vibehub/credentials`             |
| Windows | `%USERPROFILE%\.vibehub\credentials` |

<Note>
  Credentials are stored in plain text. Ensure your home directory has appropriate permissions.
</Note>

## Checking Your Status

### Who Am I?

See which account you're logged in as:

```bash theme={null}
vibe whoami
```

Output:

```
Logged in as: your.email@example.com
Profile: default
```

## Managing Profiles

Profiles let you manage multiple VibeHub accounts.

### List Profiles

```bash theme={null}
vibe profiles
```

### Switch Profile

```bash theme={null}
vibe use personal
```

### Login to a New Profile

```bash theme={null}
vibe login --profile client-work
```

## Signing Out

### Logout from Current Profile

```bash theme={null}
vibe logout
```

### Logout from Specific Profile

```bash theme={null}
vibe logout --profile work
```

This removes the stored credentials for that profile.

## Token Expiration

Authentication tokens may expire after a period of inactivity. If you see authentication errors:

```bash theme={null}
# Re-authenticate
vibe login
```

## Troubleshooting

### Browser Doesn't Open

If the browser doesn't open automatically:

1. Copy the URL printed in the terminal
2. Paste it into your browser manually
3. Complete the sign-in process

### Token Not Saved

If login succeeds but you're prompted again:

1. Check write permissions on `~/.vibehub/`
2. Ensure the credentials file isn't read-only
3. Try logging out and in again

### Wrong Account

If you logged into the wrong account:

```bash theme={null}
vibe logout
vibe login
```

Then sign in with the correct Google account.

### Multiple Google Accounts

If you have multiple Google accounts:

1. Before running `vibe login`, sign out of other Google accounts in your browser
2. Or use an incognito window for the login
3. Or use profiles to manage multiple accounts

## Security Best Practices

<AccordionGroup>
  <Accordion title="Protect Your Credentials File" icon="lock">
    Ensure `~/.vibehub/credentials` is readable only by you:

    ```bash theme={null}
    chmod 600 ~/.vibehub/credentials
    ```
  </Accordion>

  <Accordion title="Don't Share Tokens" icon="eye-slash">
    Never share your authentication tokens. They grant full access to your account.
  </Accordion>

  <Accordion title="Logout on Shared Machines" icon="right-from-bracket">
    Always logout when using shared or public computers:

    ```bash theme={null}
    vibe logout
    ```
  </Accordion>

  <Accordion title="Revoke if Compromised" icon="shield">
    If you suspect your token was compromised, log out and generate a new one by logging in again.
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Initialize Project" icon="folder-plus" href="/cli/commands/init">
    Set up VibeHub in your project
  </Card>

  <Card title="Push Code" icon="cloud-arrow-up" href="/cli/commands/push">
    Start syncing your commits
  </Card>
</CardGroup>
