What we have to accomplish:
- user open a web page where he/she signs in with Google login
- access_token and refresh_token are send to our backend server
- backend server has to read xlsx files stored on google drive (backend server makes request to Google Sheets API v4)
I used this plugin https://www.npmjs.com/package/angularx-social-login for web application using Angular 8.
Looking at the Google client api libraries for .NET - https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth there doesn't seem to be any support for setting access_token or refresh_token. Only client_id and client_secret.
My other approach was then to use REST API and it works:
static void Test()
{
string baseUrl = "https://www.googleapis.com/drive/v3/files";
string token = "ya29.ImC1B_sds9zLKAlruaMvkWqcw6vA_0oXRk4HOjLP4Du3S5TzBCg";
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
string response = client.GetStringAsync(baseUrl + "/?q=mimeType='application/vnd.google-apps.spreadsheet'").Result;
}
Is there any way that I can use Google Client .NET library to refresh access_token or do I have to use REST API for this?