小编Zee*_*had的帖子

从负载均衡器获取Orgin IP

有没有办法从GCloud的HTTP负载平衡中获取用户的原始IP?我们目前只使用网络负载平衡,并且需要移动到跨区域平衡器,尽管我们需要用户的IP来进行合规性和日志记录.

它是否传递了标题或沿着这些行的东西?

谢谢~Z

google-compute-engine google-cloud-platform

9
推荐指数
2
解决办法
6632
查看次数

从GAE请求时从make_fetch_call中删除标头(用户代理)

我有一个谷歌应用引擎(GAE)的应用程序,我使用的是Python 2.7.此应用程序从用户门户(例如Chrome)接收GET(ajax)请求.收到请求后,我准备异步连接,使用urlfetch.make_fetch_call() - GET请求从GAE外部的多个网站(比如X1,X2等)请求数据.

这适用于X1网站,但不适用于X2.开始在本地开发服务器上进行探测.在探究时我怀疑X2正在检查标题中的{'User-Agent':'Python-urllib/2.7'}标记.这是我最好的猜测,因为将此字段更改为{'User-Agent':'Mozilla/5.0'}会返回所需的结果.

所以我将代码上传到GAE并使用urlfetch.make_fetch_call()启动了该过程.在拦截此调用后,我发现无论我做什么,GAE添加的默认标头都不会被删除. 这是GAE添加的默认标题.

302 218ms 0kb Mozilla/5.0(Windows NT 6.1; WOW64)AppleWebKit/537.36(KHTML,与Gecko一样)Chrome/48.0.2564.103 Safari/537.36 AppEngine-Google; (+ http://code.google.com/appengine ; appid:s~xxx-etching-112014)module = default version = 1 107.178.194.96 - [06/Feb/2016:19:57:04 -0800] "GET/HTTP/1.1"302 383" http://www.mywebbsite.com/ ""Mozilla/5.0(Windows NT 6.1; WOW64)AppleWebKit/537.36(KHTML,与Gecko一样)Chrome/48.0.2564.103 Safari/537.36 AppEngine -Google;(+ http://code.google.com/appengine ; appid:s~xxx-etching-112014)""1.usedForIntercepting.appspot.com"ms = 218 cpu_ms = 224 cpm_usd = 0.000043 loading_request = 1 app_engine_release = 1.9.32 trace_id = fd7b7420e7f8c23371a5b0ea7e9651 instance = 00c61b117ce5ebac2a2eba44f26a01d4f2

这就是我尝试过的

for portal in self.searchPortals:
        spoofHeader = {
                       'User-agent':'Mozilla/5.0----------------------',
                       'Host':portal.getURL(),
                       'Accept-Encoding': 'identity',
                       'Connection': 'close',
                       'Accept': 'application/json, …
Run Code Online (Sandbox Code Playgroud)

google-app-engine http-headers urlfetch google-app-engine-python

6
推荐指数
1
解决办法
490
查看次数

如何在 Google Drive API v3 中获取文件的“lastModified”?

我最近决定从 Drive API v2 迁移到 v3。

在 v2 中,files().get(fileId)返回几乎所有属性,但在 v3 中,它不返回lastModified,这对我来说非常重要。无论如何我可以在v3中做到吗?

python google-api google-drive-api

5
推荐指数
1
解决办法
2533
查看次数

如何在GAE端点中检索自定义用户对象?

我刚刚在我的Google应用引擎Java应用上创建了自己的自定义身份验证.而且我正在尝试做的下一件事并不是那么麻烦.

身份验证工作正常,但现在我正在尝试向默认的User对象添加一些额外的字段,这样我就不必对服务器进行这么多的调用.

所以我到目前为止所创建的是一个实现Authenticator的自定义类.根据用户是否经过身份验证,authenticate方法返回User对象或null.然后,我的API端点可以访问用户对象.

为了扩展我的应用程序功能,我尝试扩展默认的User对象,创建一些新字段,然后将其传递给端点.但是,由于端点可访问的User对象与我扩展的用户对象不同,因此无法获取额外的字段.

MyAuthenticator.java

import com.google.api.server.spi.auth.common.User;

public class MyAuthenticator implements Authenticator {

@Override
public User authenticate(HttpServletRequest request) {
    // some code
    return new AuthUser(...)
}
Run Code Online (Sandbox Code Playgroud)

AuthUser.java

import com.google.api.server.spi.auth.common.User;

public class AuthUser extends User {
private String newToken;

public AuthUser(String email) {
    super(email);
}

public AuthUser(String id, String email) {
    super(id, email);
}

public AuthUser(String id, String email, String newToken) {
    super(id, email);
    this.newToken = newToken;
}

public String getNewToken() {
    return newToken;
}
}
Run Code Online (Sandbox Code Playgroud)

UserEndpoint.java

import com.google.appengine.api.users.User;

@Api(authenticators = …
Run Code Online (Sandbox Code Playgroud)

java authentication google-app-engine google-cloud-endpoints

4
推荐指数
1
解决办法
647
查看次数