Search code examples
javascriptc#asp.net-mvcgoogle-oauth

Google oAuth - validate user in JS, but use in C#


We have a web application that needs to synchronize scheduled events with a user's Google calendar. A Windows service will add/edit/delete Google calendar events for the user.

We are considering...

  1. In our web app we authenticate the user with the Google oAuth2 JS libraries
  2. Collect a token once the user has allowed our app to work with their calendar
  3. Save that token server side, so a Windows service can then update the user's calendar.

Is this workable? Also, how do we renew expired tokens?


Solution

  • This article explains how to do it.

    https://developers.google.com/identity/sign-in/web/server-side-flow

    TL;DR

    enter image description here