飞书扫码登录第三方应用系统


引入<script src="https://sf3-cn.feishucdn.com/obj/static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.1.js"></script>

var QRLoginObj = QRLogin({

id:"login_container",
goto: "https://passport.feishu.cn/suite/passport/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=code&state=STATE",
width: "500",
height: "500",
});
 
 
var handleMessage = function (event) {
var origin = event.origin;
// 使用 matchOrigin 方法来判断 message 是否来自飞书页面
if( QRLoginObj.matchOrigin(origin) ) {
var loginTmpCode = event.data;
// 在授权页面地址上拼接上参数 tmp_code,并跳转
window.location.href = `${goto}&tmp_code=${loginTmpCode}`;//注意此处loginTmpCode不是code,跳转之后的链接上才会返回code
}
};
 
if (typeof window.addEventListener != 'undefined') {
window.addEventListener('message', handleMessage, false);}
else if (typeof window.attachEvent != 'undefined') {
window.attachEvent('onmessage', handleMessage);
}
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM