2021年2月3日 星期三

使用 liff 取得 lineid

新增 liff app
前往 LINE Developers > Provider > channels > 點選 line login channel > liff

取得 lineid
<script src="https://static.line-scdn.net/liff/edge/2/sdk.js"></script>
liff.init({
                liffId: '...'
            }).then(function () {
                if (liff.isLoggedIn()) {
                    liff.getProfile().then(profile => {
                        alert(profile.userId); // lineid
                    });
                }
                else {
                    liff.login({ redirectUri: new URL(window.location.href) }); // 返回時保留呼叫前的參數
                }
            }).catch(function (error) {
                console.log(error);
            });

沒有留言:

自訂權限驗證機制

// 使用 filter [Route("api/[controller]")] [ApiController] [Authorize] [TypeFilter(typeof(CustomAsyncAuthorizationFilter))] public c...