public string BuildAuthenticateUrl(GrantType grantType, OAuth2Parameters parameters) { if (this.authenticateUrl != null) { return BuildAuthUrl(this.authenticateUrl, grantType, parameters); } return this.BuildAuthorizeUrl(grantType, parameters); }
private static string BuildAuthUrl(string baseAuthUrl, GrantType grantType, OAuth2Parameters parameters) { StringBuilder builder = new StringBuilder(baseAuthUrl); if (grantType == GrantType.AuthorizationCode) { builder.Append("&response_type=code"); } else if (grantType == GrantType.ImplicitGrant) { builder.Append("&response_type=token"); } if (parameters != null) { foreach (string str in parameters) { string str2 = HttpUtils.UrlEncode(str); foreach (string str3 in parameters.GetValues(str)) { builder.AppendFormat("&{0}={1}", str2, HttpUtils.UrlEncode(str3)); } } } return builder.ToString(); }
public string BuildAuthorizeUrl(GrantType grantType, OAuth2Parameters parameters) { return BuildAuthUrl(this.authorizeUrl, grantType, parameters); }
public ActionResult Tencent() { if (string.IsNullOrWhiteSpace(this.TencentAppId)) { return base.Content("该网站尚未启用腾讯微博登录"); } IOAuth2ServiceProvider<Maticsoft.OAuth.Tencent.Weibo.IWeibo> provider = new Maticsoft.OAuth.Tencent.Weibo.WeiboServiceProvider(this.TencentAppId, this.TencentSercet); OAuth2Parameters parameters2 = new OAuth2Parameters { RedirectUrl = this.RedirectTencentUrl, State = this.STATE }; OAuth2Parameters parameters = parameters2; base.Session["OAuth2CallbackState"] = this.STATE; return this.Redirect(provider.OAuthOperations.BuildAuthorizeUrl(GrantType.AuthorizationCode, parameters)); }
public ActionResult Sina() { if (string.IsNullOrWhiteSpace(this.SinaAppId)) { return base.Content("该网站尚未启用新浪微博登录"); } IOAuth2ServiceProvider<Maticsoft.OAuth.Sina.IWeibo> provider = new Maticsoft.OAuth.Sina.WeiboServiceProvider(this.SinaAppId, this.SinaSercet); OAuth2Parameters parameters2 = new OAuth2Parameters { RedirectUrl = this.RedirectSinaUrl, State = this.STATE }; OAuth2Parameters parameters = parameters2; return this.Redirect(provider.OAuthOperations.BuildAuthorizeUrl(GrantType.AuthorizationCode, parameters)); }
public ActionResult QQ() { if (string.IsNullOrWhiteSpace(this.QQAppId)) { return base.Content("该网站尚未启用QQ登录"); } IOAuth2ServiceProvider<IQConnect> provider = new QConnectServiceProvider(this.QQAppId, this.QQSercet); OAuth2Parameters parameters2 = new OAuth2Parameters { RedirectUrl = this.RedirectQQUrl, Scope = "get_user_info,add_t,add_pic_t", State = this.STATE }; OAuth2Parameters parameters = parameters2; base.Session["OAuth2CallbackState"] = this.STATE; return this.Redirect(provider.OAuthOperations.BuildAuthorizeUrl(GrantType.AuthorizationCode, parameters)); }