User Authentication
Authentication Flow
1. Wallet Connection
// Connect wallet using AppKit
import { useAppKit, useAppKitAccount } from "@reown/appkit/react";
const { open } = useAppKit();
const { address, isConnected } = useAppKitAccount();2. Message Signing
// 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:
{
"invite_code": null,
"message": "cooking.city",
"public_key": "user_wallet_public_key",
"signature": "signature_result_in_hex_format"
}Response Example:
Token Usage
Add the obtained token to request headers:
User Information Query
Endpoint: GET /api/auth/me
Request Headers:
Response Example:
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)
Last updated