I am implementing C# WPF application, where I host CefSharp web browser with Google Calendar opened. Also, I want to add events to calendar with Google Calendar API usage. I need some common entry point for both:
- logging in to Google Calendar web page
- obtaining user token for API usage
Is there any possibility to do that? I am afraid that there will be needed double authentication which would make my app much less user friendly. Here is how I am doing it now:
- Creating Google API access
using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = "token.json";
Credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
// Create Google Calendar API service.
Service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = Credential,
ApplicationName = ApplicationName
});
- Opening Google Calendar web page with CefSharp
<cefSharp:ChromiumWebBrowser Address="https://calendar.google.com/calendar/r"/>