我创建了一个项目console.developers.google.com使用Google Calendar API.我们需要生成凭证并选择应用程序类型
对于Localhost和应用程序类型,other以下是可行的Json.
{
"installed": {
"client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"project_id": "xxxxxx-00000",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "xxxxxxxxxxxx",
"redirect_uris": [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost" ]
}
}
Run Code Online (Sandbox Code Playgroud)
对于Web Application服务器上的主机应用程序类型少数参数具有不同的值,Json如下所示.
{
"web": {
"client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
"project_id": "xxxxxxxx-99999",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "xxxxxxxxxxxxxxxxxxxxxxx",
"redirect_uris": [ "http://demo.mydemo.com" ],
"javascript_origins": [ "http://demo.mydemo.com" ]
}
}
Run Code Online (Sandbox Code Playgroud)
此处,当用户(仅限已集成Google日历的用户)尝试创建活动时,Google应同意使用哪个Google帐户,并要求在重定向到重定向页面之前阅读个人数据.在同意后,它将在所选谷歌帐户的日历中添加提供的数据.问题是它没有将用户重定向到Oauth身份验证即The Consent Screen.
错误如下
System.AggregateException: One or more errors occurred. …Run Code Online (Sandbox Code Playgroud) c# asp.net-mvc google-calendar-api google-oauth google-api-dotnet-client
我正在使用Google Calendar Api我的一个项目。我不知道如何,但下面显示的错误令人不安。
里面的代码AppFlowMetadata。
public class AppFlowMetadata : FlowMetadata
{
private static readonly IAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer
{
ClientSecrets = new ClientSecrets
{
ClientId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
ClientSecret = "xxxxx_xxxxxxxxxxxxxxxxx"
},
Scopes = new[] { CalendarService.Scope.Calendar },
DataStore = new FileDataStore("Calendar.Api.Auth.Store")
});
public override string GetUserId(Controller controller)
{
var user = controller.Session["UserID"];
if (user == null)
{
user = Guid.NewGuid();
controller.Session["UserID"] = user;
}
return user.ToString();
}
public override IAuthorizationCodeFlow Flow
{
get { return …Run Code Online (Sandbox Code Playgroud) 我正在 Web 应用程序中使用 SignalR,当客户端从 Hub 收到消息时,我希望将任务栏中的浏览器图标闪烁为橙色。
Hub 内的代码。
public void PrivateMessage(string UserName, string Message)
{
Clients.All.newmessage(UserName, Message);
}
Run Code Online (Sandbox Code Playgroud)
来自集线器的响应 - Jquery 代码在 cshtml 页面中收到消息。
var chat = $.connection.chatHub;
chat.client.newmessage= function (UserName,Message) {
$("#conversation").append('<li>' + UserName + ':' + Message + '</li>');
};
Run Code Online (Sandbox Code Playgroud)
在附加消息之后,如果用户已最小化窗口,我想闪烁浏览器图标。它还应该适用于所有浏览器,即 Chrome、Firefox、Safari。
提前致谢。如果有人有解决方案,请告诉我。