Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安卓端授权后没有返回login:ok,ios授权后checksession返回session key expired #13577

Open
JMLUO opened this issue Apr 4, 2023 · 3 comments
Labels
F-vue2 Framework - Vue 2 T-swan Target - 编译到百度小程序 V-3 Version - 3.x

Comments

@JMLUO
Copy link

JMLUO commented Apr 4, 2023

相关平台

百度小程序

小程序基础库: 3.310.35
使用框架: Vue 2

复现步骤

<button open-type="login" @login="getLoginCallback" @tap="getLoginCallback">授权

发起授权-->允许授权-->获取回调出参,以及回调后调用checksession

期望结果

1、安卓端,正常返回login:ok
2、ios端,checksession返回正常

实际结果

1、安卓端,允许授权后不返回login:ok,但是checksession返回已授权
2、ios端,允许授权后返回login:ok,但是checksession返回session key expired

环境信息

👽 Taro v3.4.8


  Taro CLI 3.4.8 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 12.2.0 - C:\Program Files\nodejs\node.EXE 
      Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
      npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD 
@taro-bot2 taro-bot2 bot added F-vue2 Framework - Vue 2 T-swan Target - 编译到百度小程序 V-3 Version - 3.x labels Apr 4, 2023
@TheKonka
Copy link
Member

TheKonka commented Apr 5, 2023

480710b67a852e4d13861ea0104a5a10.mp4
a16a807e482138d3797edfc6ebf7de5f.mp4

没怎么用过百度小程序,我在最新版本(3.6.3 )试了好像正常?
代码是这样:

<template>
	<view class="index">
		<text>{{ msg }}</text>
		<button type="primary" @tap="checkSession">checkSession</button>
		<button open-type="login" @login="getLoginCallback">授权登录</button>
	</view>
</template>

<script>
import './index.scss';
import Taro from '@tarojs/taro';
export default {
	data() {
		return {
			msg: 'Hello world!',
		};
	},
	methods: {
		getLoginCallback(e) {
			console.log('登录信息:', e);
			if (e.detail.errCode === '10004' || e.detail.errCode === '904') {
				swan.showToast({
					title: '用户未登录',
					icon: 'none',
				});
				return;
			}
			swan.showToast({
				title: '用户登录成功',
				icon: 'none',
			});
		},
		checkSession() {
			swan.checkSession({
				success: (res) => {
					swan.showModal({
						title: '',
						content: '用户在小程序中 登录态有效',
					});
				},
				fail: (err) => {
					swan.showModal({
						title: '',
						content: '用户在小程序中登陆态无效,请点击下方按钮重新登录,获取有效SessionKey',
					});
				},
			});
		},
	},
};
</script>

@JMLUO
Copy link
Author

JMLUO commented Apr 6, 2023

抱歉,漏了一個重要前提,前提是宿主(百度app)未登录

@TheKonka
Copy link
Member

TheKonka commented Apr 9, 2023

82b55116868bb6bba5b4f6d7e5767e03.mp4
37f1d61bfbe161ffd0fe2b28c008e116.mp4

这样?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue2 Framework - Vue 2 T-swan Target - 编译到百度小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants