使用Javascript端点的GAE Openid联合身份验证

时间:2013-09-23 06:49:27

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

我想使用Java脚本(没有Java Servlet)端点来使用GAE Open-ID联合身份验证。

是否通过Java Script(没有Java Servlet)端点支持? 如果是,我如何在Java Script端点API调用中使用Open-ID联合身份验证?

我在端点API中尝试了用户

@ApiMethod(
        name = "signMe.signGoogleId",
        httpMethod = "POST",
        scopes = { "https://www.googleapis.com/auth/userinfo.profile" , "https://www.googleapis.com/auth/userinfo.email" }
    )
    public SignIn signInOpenId(User user)throws
      OAuthRequestException, IOException
    {

      User is null always even after logging with Google\Yahoo User.

我在端点API中尝试过HttpServletRequest req。

@ApiMethod(
        name = "SignMe.signOpenId",
        httpMethod = HttpMethod.GET,
        scopes = { "https://www.googleapis.com/auth/userinfo.profile" , "https://www.googleapis.com/auth/userinfo.email" }
    )
    public SignIn signInOpenId(HttpServletRequest req)
    throws IOException
{

UserService userService = UserServiceFactory.getUserService();
        User newUser = userService.getCurrentUser();

        newUser is null always even after logging with Google\Yahoo User.

谢谢, 迪帕克

1 个答案:

答案 0 :(得分:0)

您可以始终转储云端点的方式,并使用常规API身份验证。

https://developers.google.com/appengine/articles/openid#fa

与非云端点应用程序一样。缺点是您不会获得任何客户端授权功能,因此任何客户端代码都会命中您的API。

Google Cloud Endpoints目前,OAuth似乎不支持Open ID。