【发布时间】:2014-08-23 19:14:39
【问题描述】:
我正在 Google Cloud Endpoints 中为 Android 应用实施自定义身份验证。为此,我在 HTTP 标头中发送了一个身份验证令牌。来自安卓:
private static final String HEADER_AUTH_TOKEN = "HTTP_AUTHORIZATION";
private GoogleClientRequestInitializer requestInitializer =
new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
HttpHeaders headers = request.getRequestHeaders();
if (authPrefs.authToken().exists()) {
headers.set(HEADER_AUTH_TOKEN, authPrefs.authToken().get().toString());
}
request.setRequestHeaders(headers);
}
};
Api.Builder apiBuilder = new Api.Builder(
AndroidHttp.newCompatibleTransport(),
new GsonFactory(),
null);
return apiBuilder.setApplicationName(APPLICATION_NAME)
.setGoogleClientRequestInitializer(requestInitializer)
.build()
然后在 Python 中,我尝试检索身份验证令牌标头:
import os
auth_token = os.getenv('HTTP_AUTHORIZATION')
auth_token 为无。我错过了什么?
【问题讨论】:
标签: android python google-app-engine google-cloud-endpoints