protected void Page_Load(object sender, EventArgs e) { if (!IsCallback) { Oauthkey2 oauthKey = new Oauthkey2( StringParserHelper.GetConfig("AppKey"), StringParserHelper.GetConfig("AppSercet")); oauthKey.ParseToken(this.Request.Url.ToString()); oauthKey.callbackUrl = StringParserHelper.GetConfig("CallbackUrl"); var oauth2 = new Oauth(oauthKey); var accessToken = oauth2.GetAccessToken(); if (string.IsNullOrWhiteSpace(accessToken)) { this.Response.Write("获取Access_Token失败"); } this.Session["accessToken"] = accessToken; txtMsg.Text = "授权成功,accessToken:" + accessToken; var user = new user(oauthKey, "UTF-8").info(); txtUserInfo.Text = "账户信息:\r\n" + user; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsCallback) { var appKey = StringParserHelper.GetConfig("AppKey"); if (string.IsNullOrWhiteSpace(appKey)) { this.Response.Write("<script>alert('AppKey为空,请确认Web.Config中是否已经配置相关信息。')</script>"); return; } var appSecret = StringParserHelper.GetConfig("AppSercet"); if (string.IsNullOrWhiteSpace(appSecret)) { this.Response.Write("<script>alert('AppSecret为空,请确认Web.Config中是否已经配置相关信息。')</script>"); return; } var callbackUrl = StringParserHelper.GetConfig("CallbackUrl"); if (string.IsNullOrWhiteSpace(callbackUrl)) { this.Response.Write("<script>alert('CallbackUrl为空,请确认Web.Config中是否已经配置相关信息。')</script>"); return; } var oauthKey = new Oauthkey2(appKey, appSecret); oauthKey.callbackUrl = callbackUrl; authLink.NavigateUrl = oauthKey.urlUserAuthrize(oauthKey.callbackUrl); } }