【问题标题】:Google Cloud Endpoints: How to identify the client type?Google Cloud Endpoints:如何识别客户端类型?
【发布时间】:2017-02-28 04:07:47
【问题描述】:

在endpoints handler方法中,如何获取客户端信息。

请求是来自 Webclient 还是 Android 还是 iOS?

另外,如何判断请求是否来自API Explorer?

【问题讨论】:

  • 如果我理解你的第一个问题,你可以通过调用endpoints.get_current_user()获取当前用户,见cloud.google.com/appengine/docs/standard/python/endpoints/auth
  • @337186​​2 谢谢。我不是在寻找用户,而是在寻找用户如何尝试访问 API。是否通过浏览器/javascript(如果可能,使用哪个浏览器)、Android App 还是 iOS App?
  • 好的!对于您的最后一个问题,请查看stackoverflow.com/a/42521425/3371862中的第 1 点
  • @337186​​2:谢谢。

标签: google-app-engine google-cloud-endpoints


【解决方案1】:

User-Agent 标头按语言标识大多数官方客户端。它将包含类似于google-http-java-clientgoogle-api-java-client 的内容。对于 JavaScript,您应该查看 X-Javascript-User-Agent

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-27
    • 1970-01-01
    • 2014-05-03
    • 2014-05-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多