The Google API key is for 24th . after this expire. so i need to refresh it in my project. so I've used the following code to refresh API key in WPF c#
class refApiKey
{
/// <summary>
/// This example uses the discovery API to list all APIs in the discovery repository.
/// https://developers.google.com/discovery/v1/using.
/// <summary>
[STAThread]
public static void main()
{
try
{
new refApiKey().Run().Wait();
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.WriteLine("ERROR: " + e.Message);
}
}
}
string key;
private async Task Run()
{
// Create the service.
var service = new DiscoveryService(new BaseClientService.Initializer
{
ApplicationName = "Discovery Sample",
ApiKey = "apikey",
});
// Run the request.
var result = await service.Apis.List().ExecuteAsync();
// Display the results.
if (result.Items != null)
{
foreach (DirectoryList.ItemsData api in result.Items)
{
key=key+api.Id + " - " + api.Title;
}
}
variebls.apikey = key;
}
}
But when you run this code, the class ConfigurableMessageHandler
on line 313, return response
to the hang out .Why does this happen?
what should i do ?