Tag: dotnetopenauth

将Google OpenID迁移到OpenID Connect:openid_id不匹配

我已按照文档中的内容开始了从Google OpenID迁移到OpenID Connect with OAuth 2.0的过程。 我能够成功完成从令牌端点检索id_token中的openid_id和sub的工作流程,但是当我这样做时,openid_id与我们系统中的现有标识符不匹配。 阻止我将现有用户映射到新ID并阻止用户登录我们的应用程序(或者可能被允许以其他人身份登录)。 id的格式正确,但不匹配。 我已将openid.realm参数设置为现有的openid.realm,并将重定向设置为与文档建议的相同。 这在本地和我们的azure色托管环境中都会发生。 我正在使用JWT.JsonWebToken来解码id_token,但我也通过使用google: JWT Decoder上的web托管解码器validation它是否正确解码 ,我想出了与我们目前不匹配的相同OpenID标识符有那个用户。 我还应该注意到我已经尝试添加配置文件范围,但这没有任何区别。 我们正在使用DotNetOpenAuth.OpenId作为我们的原始系统,所以我认为问题不在那里。 我已经检查了作为响应的一部分的ClaimedIdentifier,它确实与我们在openId系统中保存的内容相匹配,因此我们不会错误地保存它。 以下是我们用于为auth请求生成Uri的内容。 它主要是DotNetOpenAuth.GoogleOAuth2客户端的修改版本。 protected static Uri GetServiceLoginUrl(Uri returnUrl) { var state = string.IsNullOrEmpty(returnUrl.Query) ? string.Empty : returnUrl.Query.Substring(1); return BuildUri(AuthorizationEndpoint, new NameValueCollection { { “response_type”, “code” }, { “client_id”, AppId }, { “scope”, “openid” }, { “prompt”, “select_account”}, { […]

Google+ API:如何在每次启动应用时使用RefreshTokens来避免请求访问权限?

我正在尝试使用Google+ API访问经过身份validation的用户的信息。 我从其中一个示例中复制了一些代码,这样可以正常工作(下图),但是我无法使其在我可以跨应用程序启动重用令牌的方式工作。 我尝试捕获“RefreshToken”属性并使用provider.RefreshToken() (以及其他内容)并始终获得400 Bad Request响应。 有谁知道如何使这项工作,或知道我在哪里可以找到一些样品? 谷歌代码网站似乎没有涵盖这个:-( class Program { private const string Scope = “https://www.googleapis.com/auth/plus.me”; static void Main(string[] args) { var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description); provider.ClientIdentifier = “BLAH”; provider.ClientSecret = “BLAH”; var auth = new OAuth2Authenticator(provider, GetAuthentication); var plus = new PlusService(auth); plus.Key = “BLAH”; var me = plus.People.Get(“me”).Fetch(); Console.WriteLine(me.DisplayName); } private […]

如何使用服务帐户通过.NET C#访问Google AnalyticsAPI V3?

我意识到这个问题之前已经被问过,但是代码示例的方式很少,所以我再问一次,但至少有一点方向。 经过几个小时的搜索,我得出了以下部分实现。 namespace GoogleAnalyticsAPITest.Console { using System.Security.Cryptography.X509Certificates; using DotNetOpenAuth.OAuth2; using Google.Apis.Analytics.v3; using Google.Apis.Analytics.v3.Data; using Google.Apis.Authentication.OAuth2; using Google.Apis.Authentication.OAuth2.DotNetOpenAuth; class Program { static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); string Scope = Google.Apis.Analytics.v3.AnalyticsService.Scopes.Analytics.ToString().ToLower(); string scopeUrl = “https://www.googleapis.com/auth/” + Scope; const string ServiceAccountId = “nnnnnnnnnnn.apps.googleusercontent.com”; const string ServiceAccountUser = “nnnnnnnnnnn@developer.gserviceaccount.com”; AssertionFlowClient client = new AssertionFlowClient( GoogleAuthenticationServer.Description, new X509Certificate2(@”7039572692013fc5deada350904f55bad2588a2a-privatekey.p12″, “notasecret”, […]