下面我的代码片段应该返回信标列表。当Google API控制台生成API密钥时,我已将我的公共IP地址列入白名单并与api密钥关联。当代码调用ExecuteAsync()方法时,我不断收到一个错误代码为403(禁止)的异常。我可能做错了什么以及如何减轻这个问题?谷歌.NET API由于错误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);
}
}
}
你添加了灯塔服务在API控制台项目? – davidgyoung
请发布完整的错误消息403禁止可能只是谷歌已经返回给你的一部分。 – DaImTo