Tag: oauth 2.0

Google OAuth2服务帐户访问令牌请求提供“无效请求”响应

我正在尝试通过服务器到服务器方法与我的应用程序启用的BigQuery API进行通信。 我已经在这个谷歌指南上勾选了我在J#中尽我所能构建JWT的所有方框。 我对Base64Url编码了所有必要的东西。 但是,我从谷歌获得的唯一回应是400 Bad Request “error” : “invalid_request” 我从其他SO问题中确认了以下所有问题: 使用RSA和SHA256正确加密签名 我正在使用POST并使用application / x-www-form-urlencoded内容类型 转义索赔集中的所有反斜杠 在POST数据中尝试了各种grant_type和断言值 当我使用Fiddler时,我得到了相同的结果。 错误消息令人沮丧地缺乏细节! 我还能尝试什么?! 这是我的代码: class Program { static void Main(string[] args) { // certificate var certificate = new X509Certificate2(@”.p12″, “notasecret”); // header var header = new { typ = “JWT”, alg = “RS256” }; // claimset var times […]

SMTP和OAuth 2

.NET是否支持通过OAuth协议进行SMTP身份validation? 基本上,我希望能够使用OAuth访问令牌发送有关用户行为的电子邮件。 但是,我在.NET框架中找不到对此的支持。 Google在其他环境中提供了一些示例 ,但不提供.NET。

如何使用服务帐户通过.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”, […]

如何使用刷新令牌续订访问令牌?

我正在使用带有OWIN的 ASP.NET MVC 5 。 我做了很多研究,但没有找到如何使用刷新令牌续订访问令牌。 我的方案是:用户第一次访问我的应用时,他或她授予访问我读取API返回的刷新令牌的帐户的权限。 当用户返回我的应用程序时,我需要根据“刷新令牌”刷新访问令牌。 有人可以提供一些代码吗? 这是我到目前为止所取得的成就: Startup.Auth.cs: var googleOAuth2AuthenticationOptions = new GoogleOAuth2AuthenticationOptions { Caption = “Google+”, ClientId = Parameters.Instance.Authentication.oAuth.GooglePlus.ClientId, ClientSecret = Parameters.Instance.Authentication.oAuth.GooglePlus.ClientSecret, CallbackPath = new PathString(“/oauth-login-return”), Provider = new GoogleOAuth2AuthenticationProvider { OnAuthenticated = async context => { context.Identity.AddClaim(new Claim(ClaimTypes.Name, context.Identity.FindFirstValue(ClaimTypes.Name))); context.Identity.AddClaim(new Claim(ClaimTypes.Email, context.Identity.FindFirstValue(ClaimTypes.Email))); context.Identity.AddClaim(new Claim(“picture”, context.User.GetValue(“picture”).ToString())); context.Identity.AddClaim(new Claim(“profile”, context.User.GetValue(“profile”).ToString())); context.Identity.AddClaim( new […]