【发布时间】:2014-04-01 16:20:49
【问题描述】:
我在一个项目中使用了 angular+cloud 端点,我想通过使用 promises 来保持它的 angular-y(这与云端点 js 库 as written here 不兼容)。我设法通过使用 $http 调用 api 来做到这一点。
例子
$http.get("/_ah/api/myapi/v1/mypath").success(function(data){
//edited for clarity
}).error(function () {
//edited for clarity
});
效果很好。
但是当我尝试在我的 api 方法中使用 User 参数时(我想让用户在我的端点中),我发现自己需要使用 OAuth 身份验证(因为通常的 web.xml 安全约束不适用于云端点)。
web.xml(安全约束)
<security-constraint>
<web-resource-collection>
<web-resource-name>All</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
端点示例 (java)
public Person getMyself(User user) throws OAuthRequestException {
// edited for clarity
return person;
}
我想知道是否有办法验证使用 Angular 的 $http 进行的 api 调用,还是我真的必须使用谷歌的端点 js 库 (gapi)?
【问题讨论】:
标签: angularjs google-cloud-endpoints