1

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:

  1. 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
});
  1. Opening Google Calendar web page with CefSharp
<cefSharp:ChromiumWebBrowser Address="https://calendar.google.com/calendar/r"/>
  • Have you checked this SO post about [Login using Google OAuth 2.0 with C#](https://stackoverflow.com/questions/24057939/login-using-google-oauth-2-0-with-c-sharp)? Also check this [blogpost](https://medium.freecodecamp.org/authentication-using-google-in-asp-net-core-2-0-5ec32c803e23) for more details. – Jessica Rodriguez Oct 25 '18 at 09:56

0 Answers0