【问题标题】:DotNetOpenAuth OAuth authorization using popup window in ASP.NetDotNetOpenAuth OAuth 授权在 ASP.Net 中使用弹出窗口
【发布时间】: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


    【解决方案1】:

    如果您想要一个支持客户端检测的库,包括通过单击按钮打开弹出窗口,您可能需要查看 javascript API:

    https://developers.google.com/api-client-library/javascript/features/authentication

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-18
      • 1970-01-01
      • 2014-05-05
      • 1970-01-01
      • 2011-10-17
      • 2013-02-22
      • 2013-03-17
      相关资源
      最近更新 更多