关于微信公众号网页开发,微信重定向地址遇坑与解决办法
发布于 4 年前 作者 taoshao 1922 次浏览 来自 分享

后#微信网页授权两种模式:

参考链接(请在微信客户端中打开此链接体验):

scope为snsapi_base

https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx520c15f417810387&redirect_uri=https%3A%2F%2Fchong.qq.com%2Fphp%2Findex.php%3Fd%3D%26c%3DwxAdapter%26m%3DmobileDeal%26showwxpaytitle%3D1%26vb2ctag%3D4_2030_5_1194_60&response_type=code&scope=snsapi_base&state=123#wechat_redirect

scope为snsapi_userinfo

https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf0e81c3bee622d60&redirect_uri=http%3A%2F%2Fnba.bluewebgame.com%2Foauth_response.php&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect

尤其注意:跳转回调redirect_uri,应当使用https链接来确保授权code的安全性。

具体见 微信文档

重定向地址不能带#如下

https://baidu.com/#/?P=adsada 这种地址经微信重定向后,会将后面的参数丢掉,微信重定向地址会变为:https://baidu.com/?code=asaasdas

正确写法:https://baidu.com/?P=asdabsdjas 重定向后就是正常的:https://baidu.com/?P=asdabsdjas&code=askljlkjlkj

1 回复

那前端岂不是不能使用hash模式路由了?

回到顶部