我一直在用
http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&safe=active&q={0}&start={1}
Run Code Online (Sandbox Code Playgroud)
在我的应用程序中搜索谷歌中的术语并返回结果.
最初它正常工作..但过了一段时间后它出错了
"疑似服务滥用行为.请参阅http://code.google.com/apis/errors "
我已经创建了console应用程序C#.哪个会upload Video从当地开车到youtube.我使用此链接在google api中创建了新应用.我还安装了所有必需的packages使用nuget.当我运行我的应用程序时,我收到错误" 访问被拒绝 "我无法找到问题.
我在Task Run()方法上遇到错误.
using System;
using System.IO;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
namespace Google.Apis.YouTube.Samples
{
/// <summary>
/// YouTube Data API v3 sample: create a playlist.
/// Relies on the Google APIs Client Library for .NET, v1.7.0 or higher.
/// See https://developers.google.com/api-client-library/dotnet/get_started
/// </summary>
internal class PlaylistUpdates …Run Code Online (Sandbox Code Playgroud) c# google-api google-data-api google-api-dotnet-client youtube-data-api
我想创建一个可以随时访问我自己的Google云端硬盘的应用程序,在那里创建文件,共享它们等等.根据https://developers.google.com/drive/service-accounts "使用常规Google帐户作为应用程序拥有的帐户"我认为我需要的唯一一步是获取access_token和refresh_token一次,将它们存储在我的应用程序中并使用refresh_token I可以刷新我的access_token(不知何故).
我可以使用https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/drive.file&redirect_uri=http://localhost;response_type=等请求获取access_token 令牌CLIENT_ID =
在用户对话框中批准此应用程序请求后,我将被重定向到我的localhost,我将获得在3600秒内到期的access_token.
问题是:
1.如何获得refresh_token?
2.如何使用refresh_token刷新access_token?
我不想使用Google的API客户端库,因为它很糟糕(.NET).
我正在尝试使用服务帐户将Dynamics CRM软件的日历同步到Google.在此过程中,我遇到了关于.net的谷歌API缺乏文档,特别是关于授权.由于使用了过时的库和类,大多数Google样本都无法编译.
所以我发现了一些关于实习和接收错误的例子.有人可以看看我的样品,告诉我做错了什么?
准备步骤:
然后创建了控制台应用程序并设法安装OAuth和Calendar nuget包.有:
有一个代码可以找到并适应我的需求:
using System;
using System.Security.Cryptography.X509Certificates;
using Google.Apis.Calendar.v3;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
namespace CrmToGoogleCalendar
{
class Program
{
static void Connect()
{
var certificate = new X509Certificate2("My Project-ee7facaa2bb1.p12", "notasecret", X509KeyStorageFlags.Exportable);
var serviceAccountEmail = "506310960175-q2k8hjl141bml57ikufinsh6n8qiu93b@developer.gserviceaccount.com";
var userAccountEmail = "<my email>@gmail.com";
var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
User = userAccountEmail,
Scopes …Run Code Online (Sandbox Code Playgroud) oauth google-calendar-api google-api google-oauth google-api-dotnet-client
我们的网站需要从后面的代码(asp.net mvc应用程序)上传视频到youtube.我正在尝试获取Google凭据,但是当我调用AuthorizeAsync时,应用程序就会挂起.我一直在寻找一个解决方案,似乎没有人帮忙.我已经搜索了谷歌和堆栈溢出的明显.我发现的大多数提到应用程序可能无法访问appdata文件夹,所以我尝试将文件夹更改为c驱动器,d驱动器和实际的inetpub位置.我测试过,发现我能够将应用程序写入这些位置.
更具体地说,用户是我们的管理员,客户将视频上传给我们,管理员批准他们.当管理员批准它们时,它会在我们的YouTube帐户上发布.管理员不应该做任何事情,只需单击批准按钮.
要使这成为一个实际问题,我该怎样做才能通过AuthorizeAsync?如果您需要更多信息,请告诉我
UserCredential credential;
GoogleWebAuthorizationBroker.Folder = "YouTube.Auth.Store";
using (var stream = new FileStream(CredentialsPath, FileMode.Open,
FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
// This OAuth 2.0 access scope allows an application to upload files to the
// authenticated user's YouTube channel, but doesn't allow other types of access.
new[] { YouTubeService.Scope.YoutubeUpload },
"user",
CancellationToken.None,
new FileDataStore("YouTube.Auth.Store")
).Result;
}
Run Code Online (Sandbox Code Playgroud) 我在发出第一个请求后收到此错误:
超出了服务“mybusinessaccountmanagement.googleapis.com”的配额指标“请求”和限制“每分钟请求数”的配额
第一次请求后如何才能超出配额?
if(File.Exists(ApplicationVariables.CertPath)) {
GoogleCredential credential;
using (var stream = new FileStream(ApplicationVariables.CertPath, FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream).CreateScoped("https://www.googleapis.com/auth/business.manage");
}
// Create the service.
var service = new MyBusinessAccountManagementService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Google Reviews Downloader",
});
//var bookshelves = await service.Mylibrary.Bookshelves.List().ExecuteAsync();
var accounts = await service.Accounts.List().ExecuteAsync();
Console.WriteLine("accounts:" + accounts);
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用asp.net应用程序中的Google Drive API上传文件.
问题:代码在本地工作,但上传到服务器时没有任何反应(页面只是继续加载...没有同意屏幕显示.帮助appreaciated."UploadedPdf"文件夹是可写的,client_secrets.json存在于该文件夹中.
注意:我没有在服务器上安装任何内容,只是将包含Google API dll的所有文件上传到服务器的bin文件夹中.
UserCredential credential;
using (var filestream = new FileStream(Server.MapPath("UploadedPdf/client_secrets.json"),
FileMode.Open, FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(filestream).Secrets,
new[] { DriveService.Scope.Drive },
"user",
CancellationToken.None,
new FileDataStore(Server.MapPath("UploadedPdf/"))).Result;
}
// Create the service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Drive API Sample",
});
Google.Apis.Drive.v2.Data.File body = new Google.Apis.Drive.v2.Data.File();
body.Title = "My document";
body.Description = "A test document";
body.MimeType = "text/plain";
byte[] byteArray = System.IO.File.ReadAllBytes(Server.MapPath("UploadedPdf/sample.txt"));
System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
FilesResource.InsertMediaUpload request = …Run Code Online (Sandbox Code Playgroud) c# asp.net google-api google-drive-api google-api-dotnet-client
更改了firebase授权系统后,我正在尝试从google auth服务器中检索c#中的访问令牌.
根据新文档:https://firebase.google.com/docs/reference/rest/database/user-auth#section-api-usage
我在c#中创建了类似的东西:
using Google.Apis.Auth.OAuth2;
[...]
async Task<string> GetToken()
{
GoogleCredential credential;
using (var stream = new System.IO.FileStream("gckey.json",
System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream).CreateScoped(
new string[] { "https://www.googleapis.com/auth/firebase.database" }
);
}
ITokenAccess c = credential as ITokenAccess;
return await c.GetAccessTokenForRequestAsync();
}
Run Code Online (Sandbox Code Playgroud)
gckey.json是从Google Developer Console下载的特定firebase项目的密钥文件.
代码工作正常,但它返回不与firebase一起使用的令牌,我试过:
https://fiery-torch-xxxx.firebaseio.com/.json?access_token=retrived token
但我收到:
"error" : "Permission denied."
我究竟做错了什么?或者我错过了什么?
我正在使用Google API Preview(1.7.0)通过OAuth2授权用户.我一直在关注示例MVC代码.这是我的实施FlowMetadata:
private static readonly IAuthorizationCodeFlow flow = ...; // Implementation of tokens
public static async Task<Google.Apis.Auth.OAuth2.Web.AuthorizationCodeWebApp.AuthResult> GetCredentials(Controller controller, CancellationToken cancellationToken) {
var result = await new AuthorizationCodeMvcApp(controller, new Models.Generic.AppFlowMetadata()).AuthorizeAsync(cancellationToken);
if (result.Credential != null)
{
// Struggling here. How do I make a request to get the e-mail address?
}
}
Run Code Online (Sandbox Code Playgroud)
我现在有一个有效的UserCredential访问令牌,但我找不到任何托管API来访问用户信息.我确实找到了这个问题,但这似乎假设我只是提出原始请求,而不是使用官方库.
如何获取用户的电子邮件地址?
所以我有这个代码
我的问题是如果我已经通过OAuth验证了如何配置UserCredential?
目前的情况是代码将显示另一个重定向到谷歌的登录页面.由于我已经使用asp.net MVC通过OAuth进行了身份验证,我已经拥有令牌如何摆脱GoogleWebAuthorizationBroker并直接传递令牌?
string[] scopes = new string[] {PlusService.Scope.PlusLogin,
PlusService.Scope.UserinfoEmail,
PlusService.Scope.UserinfoProfile};
UserCredential credential =
GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
{
ClientId = "xxx.apps.googleusercontent.com",
ClientSecret = "xxxx"
},
scopes,
Environment.UserName,
CancellationToken.None,
new FileDataStore("Store")).Result;
PlusService service = new PlusService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "ArcaneChatV2",
});
PeopleResource.ListRequest listPeople = service.People.List("me", PeopleResource.ListRequest.CollectionEnum.Visible);
listPeople.MaxResults = 10;
PeopleFeed peopleFeed = listPeople.Execute();
var people = new List<Person>();
Run Code Online (Sandbox Code Playgroud)
我对这种东西不熟悉.
c# ×6
google-api ×5
asp.net ×2
asp.net-mvc ×2
.net ×1
firebase ×1
google-oauth ×1
oauth ×1
rest ×1
youtube ×1