예제 #1
0
        public async Task LoginWithAuthDataWithUnionId()
        {
            string uuid = Guid.NewGuid().ToString();
            Dictionary <string, object> authData = new Dictionary <string, object> {
                { "expires_in", 7200 },
                { "openid", uuid },
                { "access_token", uuid }
            };
            string unionId = Guid.NewGuid().ToString();

            LCUserAuthDataLoginOption option = new LCUserAuthDataLoginOption();

            option.AsMainAccount = true;
            LCUser currentUser = await LCUser.LoginWithAuthDataAndUnionId(authData, "weixin_app", unionId, option : option);

            TestContext.WriteLine(currentUser.SessionToken);
            Assert.NotNull(currentUser.SessionToken);
            string userId = currentUser.ObjectId;

            TestContext.WriteLine($"userId: {userId}");
            TestContext.WriteLine(currentUser.AuthData);

            await LCUser.Logout();

            currentUser = await LCUser.GetCurrent();

            Assert.IsNull(currentUser);

            currentUser = await LCUser.LoginWithAuthDataAndUnionId(authData, "weixin_mini_app", unionId, option : option);

            TestContext.WriteLine(currentUser.SessionToken);
            Assert.NotNull(currentUser.SessionToken);
            Assert.AreEqual(currentUser.ObjectId, userId);
            TestContext.WriteLine(currentUser.AuthData);
        }