MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / add_token

Method add_token

src/core/database.py:929–960  ·  view source on GitHub ↗

Add a new token

(self, token: Token)

Source from the content-addressed store, hash-verified

927
928 # Token operations
929 async def add_token(self, token: Token) -> int:
930 """Add a new token"""
931 async with self._connect(write=True) as db:
932 cursor = await db.execute("""
933 INSERT INTO tokens (st, at, at_expires, email, name, remark, is_active,
934 credits, user_paygate_tier, current_project_id, current_project_name,
935 image_enabled, video_enabled, image_concurrency, video_concurrency,
936 captcha_proxy_url, extension_route_key,
937 protocol_mode, google_cookies, login_account, login_password,
938 proxy_url, auto_refresh_enabled, refresh_interval_minutes,
939 last_st_refresh_at, last_st_refresh_result)
940 VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
941 """, (token.st, token.at, token.at_expires, token.email, token.name, token.remark,
942 token.is_active, token.credits, token.user_paygate_tier,
943 token.current_project_id, token.current_project_name,
944 token.image_enabled, token.video_enabled,
945 token.image_concurrency, token.video_concurrency,
946 token.captcha_proxy_url, token.extension_route_key,
947 token.protocol_mode, token.google_cookies, token.login_account,
948 token.login_password, token.proxy_url, token.auto_refresh_enabled,
949 token.refresh_interval_minutes, token.last_st_refresh_at,
950 token.last_st_refresh_result))
951 await db.commit()
952 token_id = cursor.lastrowid
953
954 # Create stats entry
955 await db.execute("""
956 INSERT INTO token_stats (token_id) VALUES (?)
957 """, (token_id,))
958 await db.commit()
959
960 return token_id
961
962 async def get_token(self, token_id: int) -> Optional[Token]:
963 """Get token by ID"""

Callers 4

add_tokenFunction · 0.45
import_tokensFunction · 0.45
plugin_update_tokenFunction · 0.45
asyncSetUpMethod · 0.45

Calls 1

_connectMethod · 0.95

Tested by 1

asyncSetUpMethod · 0.36