---------------------------目录----------------------------------
QQ登录整合/oauth2.0认证-01-申请appkey和appid
---------------------------正文----------------------------------
上一节里面有些代码有点无用,其实我们紧紧是封装出一个地址,然后让用户点击某个按钮,跳转到这个地址上面罢了
所以在第二节中,我们可以将代码修改成下面的
QQSettingConfig qqSettingConfig = MySiteConfig.GetConfig<QQSettingConfig>();//配置对象 配置QQ的 app id appkey 回调地址 //按钮事件 protected void ButtonQQLogin_Click(object sender, EventArgs e) { string salt = new Random(100000).Next(99, 99999).ToString();//随机数 string callback = System.Web.HttpUtility.UrlEncode(qqSettingConfig.CallBackAddress+"/AuthLogin/QQCallBack.aspx", Encoding.UTF8);//回调处理地址 string url = string.Format("https://graph.qq.com/oauth2.0/authorize?client_id={0}&response_type=code&redirect_uri={1}&state={2}", qqSettingConfig.APPID, callback, salt);//互联地址 Response.Redirect(url); }
在第一节的时候,我们在填写QQ互联的信息的时候,回调地址,可能需要改一下,这里可能原因是腾讯那边对接口进行了调整导致的
本人记得以前不是这样的。
我们修改如下
在下方添加一个协助者账号,这个账号是用来登录测试的,我们知道在审核未通过之前,腾讯方面为了保障其他账号的安全,不允许未审核的账号通过QQ登录你的账号
但是腾讯方面提供了一个填写