> For the complete documentation index, see [llms.txt](https://cooking-city-launchpad.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cooking-city-launchpad.gitbook.io/docs/api-documentation/user-authentication.md).

# User Authentication

### Authentication Flow

#### 1. Wallet Connection

```javascript
// Connect wallet using AppKit
import { useAppKit, useAppKitAccount } from "@reown/appkit/react";

const { open } = useAppKit();
const { address, isConnected } = useAppKitAccount();
```

#### 2. Message Signing

```javascript
// Sign fixed message
const messageToSign = "cooking.city";
const encodedMessage = new TextEncoder().encode(messageToSign);
const signature = await walletProvider.signMessage(encodedMessage);
```

#### 3. Login to Obtain Token

**Endpoint**: `POST /api/auth/solana/login`

**Request Parameters**:

```json
{
  "invite_code": null,
  "message": "cooking.city",
  "public_key": "user_wallet_public_key",
  "signature": "signature_result_in_hex_format"
}
```

**Response Example**:

```json
{
  "code": 200,
  "data": {
    "profile": {
      "address": "user_wallet_address",
      "avatar_url": null,
      "bio": null,
      "created_at": "2024-01-01T00:00:00Z",
      "nick_name": "user_nickname"
    },
    "token": "jwt_token_string"
  }
}
```

### Token Usage

Add the obtained token to request headers:

```
Authorization: Bearer your_jwt_token
```

### User Information Query

**Endpoint**: `GET /api/auth/me`

**Request Headers**:

```
Authorization: Bearer your_jwt_token
```

**Response Example**:

```json
{
  "code": 200,
  "data": {
    "profile": {
      "address": "user_wallet_address",
      "avatar_url": "avatar_url",
      "bio": "user_bio",
      "created_at": "creation_time",
      "nick_name": "nickname",
      "twitter_screen_name": "twitter_username",
      "telegram_username": "telegram_username",
      "points": "points_amount"
    }
  }
}
```

### Key Points

* Fixed signing message: `"cooking.city"`
* Signature result must be converted to hex format
* Token expiration is set according to business requirements
* Supports invitation code mechanism (invite\_code can be null)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cooking-city-launchpad.gitbook.io/docs/api-documentation/user-authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
