
[英]EndPoints API authentification on GAE python with an Android client
[英]Securing API calls GAE endpoints
我正在将移动应用程序编写为从服务器获取数据的瘦客户端。 我正在使用Google App Engine托管后端,并使用它们提供的所有服务。 我正在使用端点公开我的API。 我找到本教程来保护我的API。 我通过api资源管理器进行了测试,一切正常。 如果我未使用Oauth 2,则无法使用API。 但是,当我调查HTTP标头时,找不到“ authorization:bearer”行,该行包含用于认证和授权API调用的一次性令牌。 现在我怀疑我没有正确的方法,因为通常我必须看到这条线。 尽管没有我之前指出的那一行,但我的电话的屏幕截图显示了请求已执行。 我的代码也有一部分是由Android Studio生成的。
@ApiMethod(
name = "get",
path = "offer/{id}",
httpMethod = ApiMethod.HttpMethod.GET)
public Offer get(@Named("id") long id, User user) throws NotFoundException, UnauthorizedException {
if (user == null) throw new UnauthorizedException("User is Not Valid");
logger.info("Getting Offer with ID: " + id);
Offer offer = ofy().load().type(Offer.class).id(id).now();
if (offer == null) {
throw new NotFoundException("Could not find Offer with ID: " + id);
}
return offer;
}
关于为什么缺少包含令牌的行的任何线索?
您可能希望登录user.getUserId(),user.getNickname()和user.getEmail()以查看发生了什么。
我认为存在cookie和其他方式来存储身份验证信息,因为我很少需要两次登录网站。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.