0

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 ?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
zfarzaneh
  • 55
  • 10

1 Answers1

0

A really simple Basic API example in C# is here. This project uses the .NET client from NuGet.

PlusService plusService = new PlusService(
                new Google.Apis.Services.BaseClientService.Initializer()
                {
                    ApiKey = API_KEY
                });
Person me = plusService.People.Get(@"+GusClass").Execute();

As mentioned before, you do not need to refresh an API key.

class
  • 8,621
  • 29
  • 30