学习如何使用 OPC OS 构建和发布你的应用
// 安装 SDK
npm install @opc/auth
// 在你的应用中使用
import { OPCAuth } from '@opc/auth'
const auth = new OPCAuth({
clientId: 'your-app-id',
redirectUri: 'https://your-app.com/callback',
})
// 发起登录
auth.signIn()
// 检查登录状态
if (auth.isAuthenticated()) {
const user = auth.getUser()
console.log('已登录:', user.nickname)
}