Determine whether the current environment is WeChat

var rpId = 'NAN'
//rpId为后端返回的
var ua = navigator.userAgent.toLowerCase();  
	if(ua.match(/MicroMessenger/i)=="micromessenger"){
    
    
							window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx39adce469ffe9ef8&redirect_uri=https%3A%2F%2Fwww.shirenzuile.com%2Fsrz-h5%2Fh5%2Flogin%2Flogin&response_type=code&scope=snsapi_userinfo&state='+rpId+',1,NaN#wechat_redirect';
}

Webpage authorization official website address
https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html

scope is 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

Special attention: the redirect callback redirect_uri should use the https link to ensure the security of the authorization code.

Guess you like

Origin blog.csdn.net/weixin_49295874/article/details/114574443