【问题标题】:How to access the Books API from a web application hosted on Microsoft Azure?如何从托管在 Microsoft Azure 上的 Web 应用程序访问 Books API?
【发布时间】:2016-01-20 08:38:15
【问题描述】:

我已经构建了一个非常简单的网络应用程序,它使用 Google Books API 来检索用户提供的 ISBN 的卷信息。该应用程序使用官方 C# 库。请求通过 API 密钥进行授权。

在本地计算机上运行应用程序时,我使用德国 IP 地址访问服务,一切正常。但是,从 Microsoft Azure 访问 Books API 时出现以下错误:

Google.Apis.Requests.RequestError
无法确定地理受限操作的用户位置。 [403]
错误 [
消息[无法确定地理限制操作的用户位置。]
位置[ - ]
原因[未知位置]
域[全球]
]

有谁知道如何从托管在 Microsoft Azure 中的 Web 应用程序访问 Google Books API?

【问题讨论】:

  • 哇好消息!天蓝色服务器托管在哪里?我想测试一下。
  • @DaImTo 该应用程序托管在“西欧”。

标签: google-api azure-web-app-service google-api-dotnet-client ip-geolocation google-books


【解决方案1】:

好吧,我不知道这是否可行。但是您可以在请求中提供 IP 地址。如果它没有让我知道,这可能会也可能不会起作用,我会删除它。

var bookService = new BooksService(new BaseClientService.Initializer()
    {
     ApiKey = "xxxx",
     ApplicationName = "BooksService Authentication Sample",
    });


var request = bookService.Bookshelves.List("user");
request.UserIp = "";  //<-- find an ip address to feed it
var result = request.Execute();

问题是 Google 通常会获取请求来自的 IP 地址。我想知道为什么它不能从 Azure 发送请求的 IP 地址中获取地理位置。

【讨论】:

  • 谢谢 - 值得一试;)
  • 交叉手指。如果它不起作用,我知道在 Google 给谁发电子邮件:)
  • 好吧——也许这不完全是谷歌的错:blogs.msdn.com/b/mast/archive/2014/05/10/…
  • 要通过电子邮件将此发送给客户端库上的开发人员,看看他是否有任何想法。
  • 据我所知,userIp 用于破解配额。我希望它也能解决这个问题。在我们收到他的消息之前,有问题的开发人员将在美国过一段时间。我会及时通知你。
猜你喜欢
  • 1970-01-01
  • 2013-03-31
  • 2022-01-20
  • 1970-01-01
  • 2021-11-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多