【发布时间】:2013-07-10 04:10:36
【问题描述】:
我需要使用 弹出窗口 进行 Google OAuth 身份验证。我正在使用 DotNetOpenAuth 库进行身份验证,并且它在同一页面上工作。如何在弹出窗口中执行此操作。我通过谷歌搜索环顾四周,发现很少,其中一个是“Specify request parameters in dotnetopenauth 4”但是我使用这个库的方式我不知道在哪里可以设置弹出窗口。
这是我的代码。
私有字符串 AccessToken { 获取{返回(字符串)会话[“GoogleAccessToken”]; } 设置 { 会话 [“GoogleAccessToken”] = 值; } }
private static readonly GoogleClient googleClient = new GoogleClient
{
ClientIdentifier = ConfigurationManager.AppSettings["googleConsumerKey"],
ClientCredentialApplicator = ClientCredentialApplicator.PostParameter(ConfigurationManager.AppSettings["googleConsumerSecret"]),
};
protected void Page_Load(object sender, EventArgs e)
{
if (googleClient != null)
{
if (!IsPostBack)
{
var authorization = googleClient.ProcessUserAuthorization();
if (authorization != null)
{
this.AccessToken = authorization.AccessToken;
}
else if (this.AccessToken == null)
{
googleClient.RequestUserAuthorization(scope: new[] { GoogleClient.Scopes.WebMaster.SiteVerification, GoogleClient.Scopes.WebMaster.WebMasterTools });
}
}
}
}
private static readonly AuthorizationServerDescription GoogleDescription = new AuthorizationServerDescription {
TokenEndpoint = new Uri("https://accounts.google.com/o/oauth2/token"),
AuthorizationEndpoint = new Uri("https://accounts.google.com/o/oauth2/auth"),
ProtocolVersion = ProtocolVersion.V20,
};
你能帮我解决这个问题吗(我是 ASP.Net 的新手)?谢谢
【问题讨论】:
标签: asp.net google-api oauth-2.0 dotnetopenauth google-oauth