我下面的代码片段应该返回信标列表。当让 Google API 控制台生成 API 密钥时,我已将我的公共 IP 地址列入白名单并与 api 密钥相关联。当代码调用 ExecuteAsync() 方法时,我不断收到错误代码 403(禁止)的异常。我可能做错了什么以及如何缓解这个问题?
public async void TestApiKey()
{
var apikey = "739479874ABCDEFGH123456"; //it's not the real key I'm using
var beaconServices = new ProximitybeaconService(new Google.Apis.Services.BaseClientService.Initializer
{
ApplicationName = "My Project",
ApiKey = apikey
});
var result = await beaconServices.Beacons.List().ExecuteAsync();
// Display the results.
if (result.Beacons != null)
{
foreach (var api in result.Beacons)
{
Console.WriteLine(api.BeaconName + " - " + api.Status);
}
}
}