vue-ydph-authing
v1.6.9
Published
authing对接的npm工具
Readme
托管页对接authing - 兼容vue2、vue3
安装
npm install vue-ydph-authing引入
import ydphAuthing from 'vue-ydph-authing'登录
在需要登录的地方写入以下代码
// 配置
const config = {
appKey: '', // 接口请求头中携带,找架构沟通获取
authType: "authingCodeAuth", // 写死 - 如果需要其他认证方式,和架构沟通
appId: '', // 应用的appId - 从Authing平台获取
redirectUri: '', // 登录回调地址 - 从Authing平台获取
host: '', // 从应用面板 - 单点登录 - 配置 - 应用面板获取
authUrl: "/base-gateway/auth", // code换token的接口地址 - 不用改
logoutUrl: "/base-gateway/auth/logout", // 网关退出的接口地址 - 不用改
authFailCallback: ()=>{}, // 是一个函数,auth接口失败的回调
}
// 初始化
ydphAuthing.init(config).then(userInfo => {
// userInfo就是authing返回的用户数据
console.log('authing返回userInfo', userInfo)
})退出
- 正常退出
ydphAuthing.baseGatewayLogout()- 401退出
注意: 401退出,登录后会重定向到退出时的页面,如果不需要重定向,可用正常退出
ydphAuthing.logoutFor401()