Fastapi Qr Login Skill logo

Fastapi Qr Login Skill

Community
jiushiwon
fastapi-qr-login-skill

实现小程序或微信扫码登录功能,提供完整的后端 API 接口

Overview

Publisherjiushiwon
Repositorywg-skills
Skill namefastapi-qr-login-skill
Stars
123
Forks
38
Bundled files
4
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by jiushiwon on GitHub. Read the source before you install it.

Installation

Install the Fastapi Qr Login Skill AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/python/fastapi-qr-login-skill
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jiushiwon/wg-skills.git /tmp/wg-skills
mkdir -p .claude/skills
cp -r /tmp/wg-skills/vibeCoding/backend/python/fastapi-qr-login-skill .claude/skills/fastapi-qr-login-skill
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Fastapi Qr Login Skill in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Fastapi Qr Login Skill on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Fastapi Qr Login Skill is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

FastAPI 扫码登录技能

功能概述

实现网站生成二维码、小程序扫码确认登录的完整流程。包含以下核心功能:

  1. 扫码登录会话管理 - 创建会话、轮询状态、标记已扫描、确认登录
  2. 微信小程序码生成 - 生成带场景值的小程序码,扫一扫直达确认页
  3. JWT Token 生成 - 登录成功后返回 JWT Token

适用场景

  • 网站/Web应用需要通过小程序扫码登录
  • 需要在多个平台(Web + 小程序)实现统一登录

技术栈

  • FastAPI
  • MongoDB(存储会话)
  • JWT(用户认证)
  • 微信小程序 API(生成小程序码)

技能使用方法

1. 参考实现

参考 references/impl/ 目录下的完整实现代码:

  • qr_login.py - 核心登录 API(创建会话、轮询状态、扫码、确认)
  • models.py - 数据模型(如需分离)
  • test_qr_login.py - 测试用例

2. 依赖配置

确保 app/config.py 中配置以下环境变量:

python
# 微信小程序配置
WX_APPID = "your_appid"
WX_APPSECRET = "your_appsecret"
WX_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token"

3. 路由集成

在 app/main.py 或 app/routers/__init__.py 中注册路由:

python
from app.routers import qr_login
app.include_router(qr_login.router)

4. 数据库集合

确保 MongoDB 中存在 qr_sessions 集合,用于存储登录会话。

API 接口清单

方法路径说明调用方
POST/auth/qr/create创建扫码会话Web前端
GET/auth/qr/status/{session_id}轮询会话状态Web前端
POST/auth/qr/scan小程序扫码标记小程序
POST/auth/qr/confirm确认登录小程序
GET/auth/qr/wxacode/{session_id}生成小程序码Web前端

业务流程

Web端                              小程序端
  │                                   │
  ├─ POST /auth/qr/create ──────────>│
  │<─ 返回 session_id ───────────────┤
  │                                   │
  ├─ 生成二维码 (含 session_id) ─────>│
  │                                   │
  │      用户扫码 ───────────────>   │
  │                                   │
  │                           POST /auth/qr/scan
  │<─ 轮询 /status ──────────────>   │
  │<─ status: scanned ──────────────┤
  │                                   │
  │                           显示确认弹框
  │                           用户点击确认
  │                           POST /auth/qr/confirm
  │                                   │
  ├─ 轮询 /status ──────────────>   │
  │<─ status: confirmed, token ──────┤
  │                                   │
  │  使用 token 登录成功              │

前端配合

Web 端

  1. 调用 /auth/qr/create 获取 session_id
  2. 将 session_id 编码为二维码(或调用 /auth/qr/wxacode/{session_id} 获取小程序码图片)
  3. 轮询 /auth/qr/status/{session_id} 直到返回 status: confirmed
  4. 拿到 token 后存储到本地,完成登录

小程序端

  1. 解析二维码/小程序码中的 scene 参数获取 session_id
  2. 用户进入确认页后,调用 /auth/qr/scan 标记已扫描
  3. 用户点击确认按钮后,调用 /auth/qr/confirm 完成登录

注意事项

  1. 会话有效期 - 默认 5 分钟,过期后状态变为 expired
  2. 并发处理 - 防止同一会话被多个账号扫码,使用状态和用户 ID 条件更新
  3. 微信 access_token 缓存 - 缓存已获取的 token,提前 60 秒刷新
  4. 时区处理 - MongoDB 返回 naive datetime,统一转换为 aware datetime 比较

触发词

fastapi-qr-login、FastAPI 扫码登录技能

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Fastapi Qr Login Skill AI skill do?

实现小程序或微信扫码登录功能,提供完整的后端 API 接口

Why use Fastapi Qr Login Skill on TypingMind?

Because you install it once and use it with any model. Fastapi Qr Login Skill is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Fastapi Qr Login Skill in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/jiushiwon/wg-skills/tree/main/vibeCoding/backend/python/fastapi-qr-login-skill. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Fastapi Qr Login Skill?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Fastapi Qr Login Skill?

As many as you like. As long as a model supports skills, you can use Fastapi Qr Login Skill with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Fastapi Qr Login Skill AI skill free?

Yes. It is published on GitHub by jiushiwon under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇