I was creating the sample to get all the google calendar events and show the events with details on list. But it always throws the exception while fetching the data.
I tried to get events by follow the below link https://www.c-sharpcorner.com/article/get-and-create-google-calendar-events-from-net/
and i also refer the google link also https://developers.google.com/api-client-library/dotnet/get_started#simple
The issue was raised on make a request and i tried with both API key and client service.
I created the calendar credential by
GoogleCredential credential;
using(var stream = new FileStream(keyfilepath, FileMode.Open, FileAccess.Read)) {
credential = GoogleCredential.FromStream(stream)
.CreateScoped(Scopes).CreateWithUser("demo123@gmail.com");
}
var service = new CalendarService(new BaseClientService.Initializer() {
HttpClientInitializer = credential,
ApplicationName = "Calendar Sample",
});
EventsResource.ListRequest request = service.Events.List("primary");
Events events = request.Execute(); /// Makes crash
Android Crash : System.Net.WebException: 'Unable to resolve host "oauth2.googleapis.com": No address associated with hostname'
Windows : Google.Apis.Auth.OAuth2.Responses.TokenResponseException: 'Error:"unauthorized_client", Description:"Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested.", Uri:""'
Suggest me to resolve the problem.