Tag: 谷歌 的OAuth

Google使用服务帐户协调OAuth2

我有一个带有Google Coordinate .Net库和服务帐户开放认证的C#控制台应用程序。 private const string SERVICE_ACCOUNT_EMAIL = “XXX@developer.gserviceaccount.com”; private const string SERVICE_ACCOUNT_PKCS12_FILE_PATH = @”\YYY-privatekey.p12″; private const string GOOGLE_COORDINATE_TEAM_ID = “ZZZ”; private CoordinateService BuildService() { X509Certificate2 certificate = new X509Certificate2(SERVICE_ACCOUNT_PKCS12_FILE_PATH, “notasecret”, X509KeyStorageFlags.Exportable); var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate){ ServiceAccountId = SERVICE_ACCOUNT_EMAIL, Scope = CoordinateService.Scopes.Coordinate.GetStringValue() }; var auth = new OAuth2Authenticator(provider, AssertionFlowClient.GetState); return new CoordinateService(new BaseClientService.Initializer(){ […]

我在哪里可以找到ServiceAccountCredential

我在使用asp.net c#的google api工作,我的目标是使用服务帐户访问google api。 我已导入所有需要的dll以创建服务帐户以访问管理员function(admin sdk)。 但我找不到ServiceAccountCredential。 我如何在我的项目中实现这一点?

Google Analytics嵌入API服务器端授权不使用C#呈现图表

我正在尝试使用C#中的服务器端授权来呈现图表,但我无法做到这一点。 谷歌有一个例子,但基于Python,我需要基于C#MVC构建: https : //ga-dev-tools.appspot.com/embed-api/server-side-authorization/ 我创建了服务帐户并下载了JSON文件: 的Controler public class StatsController : Controller { // GET: Stats public async Task Index() { var json = “C:\\temp\\client_secrets.json”; string[] scopes = new string[] { AnalyticsReportingService.Scope.AnalyticsReadonly }; // Put your scopes here var stream = new FileStream(json, FileMode.Open, FileAccess.Read); var credential = GoogleCredential.FromStream(stream); credential = credential.CreateScoped(scopes); try { Task […]

如何在.net中使用Google OAuth2使用ServiceAccount?

是否有任何示例如何使用.net中的服务帐户访问Google服务API? private const string SERVICE_ACCOUNT_EMAIL = “xxxxxxxxxxx@developer.gserviceaccount.com”; private const string SERVICE_ACCOUNT_PKCS12_FILE_PATH = @”\path\test-privatekey.p12″; static DriveService BuildService() { X509Certificate2 certificate = new X509Certificate2(SERVICE_ACCOUNT_PKCS12_FILE_PATH, “notasecret”, X509KeyStorageFlags.Exportable); var provider = new AssertionFlowClient(GoogleAuthenticationServer.Description, certificate) { ServiceAccountId = SERVICE_ACCOUNT_EMAIL, Scope = DriveService.Scopes.Drive.GetStringValue(), }; var auth = new OAuth2Authenticator(provider, AssertionFlowClient.GetState); return new DriveService((new BaseClientService.Initializer() { Authenticator = auth }); } 这在返回OAuth连接时不成功。 […]

将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”}, { […]

.NET Google api 1.7 beta使用刷新令牌进行身份validation

我一直在关注Oauth .Net Google Apis,以便通过OAuth进行身份validation并使用Google驱动Apis。 具体来说,我想使用我已经存储的刷新令牌,以便使用它来实例化GoogleDrive服务。 我找到了像https://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.SimpleOAuth2/Program.cs?repo=samples这样的示例 这似乎使用“GoogleWebAuthorizationBroker.AuthorizeAsync”,但我不确定如何使用该方法使用刷新令牌而不是您在此示例中似乎提供的客户机密码。

Google.GData.Client.GDataRequestException – 旧代码中的身份validation突然失败

尝试在Google云端硬盘上validation和访问电子表格时,我突然开始出现以下exception: 未处理的exception:Google.GData.Client.GDataRequestException:执行aut hentication请求返回意外结果:Google.GData.Client.Utilities.QueryClientLoginToken上的Google.GData.Client.Utilities.getAuthException(TokenCollection tokens,Htt pWebResponse响应)中的404 GDataCredentials gc,S service service,String applicationName,Boolean fUseKeepAlive,IWebProxy prox yServer,Uri clientLoginHandler)at Google.GData.Client.GDataGAuthRequest.QueryAuthToken(GDataCredentials gc)at Google.GData.Client.GDataGAuthRequest.EnsureCredentials()at Google.GData .Client.GDataRequest.EnsureWebRequest()位于Google.GData的Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)上的Google.GData.Client.GDataRequest.Execute()Google.GData.Client.GDataGAuthRequest.EnsureWebRequest() Google.GData.Client.Service.Query(FeedQu)上的.Client.GDataGAuthRequest.Execute()at Google.GData.Client.Service.Query(Uri queryUri,DateTime ifModifiedSince,String etag,Int64&contentLength) 来自GoogleLogger.GoogleService.getLastXECLogRows(String folderName,String fileName,Int32 rows)的Google.GData.Documents.DocumentsService.Query(DocumentsListQuery feedQuery)的ery feedQuery) 这是代码已经运行了两年没有任何问题。 我首先想到我可能已经失去了我的生产系统的访问权限,但谷歌驱动器在我的网络浏览器中加载得很好。 在其他几个系统上尝试过它并且得到了相同的结果。 他们今天在Google API中有什么变化吗? 这不可能是巧合!

Google API V 3.0 .Net库和Google OAuth2如何处理刷新令牌

在我的应用程序中,我使用带有Google OAuth2的Google API V 3.0 .Net库来同步Google日历和Outlook日历。 我使用下面的代码来获取Google.Apis.Calendar.v3.CalendarService服务对象。 在身份validation期间,我存储了Json文件,并从中请求了Google.Apis.Auth.OAuth2.UserCredential对象。 private Google.Apis.Auth.OAuth2.UserCredential GetGoogleOAuthCredential() { GoogleTokenModel _TokenData = new GoogleTokenModel(); String JsonFilelocation = “jsonFileLocation; Google.Apis.Auth.OAuth2.UserCredential credential = null; using (var stream = new FileStream(JsonFilelocation, FileMode.Open, FileAccess.Read)) { Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.Folder = “Tasks.Auth.Store”; credential = Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync( Google.Apis.Auth.OAuth2.GoogleClientSecrets.Load(stream).Secrets, new[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar }, “user”, CancellationToken.None, new FileDataStore(“OGSync.Auth.Store”)).Result; } return credential; } 请求服务对象代码是: Google.Apis.Calendar.v3.CalendarService […]