gpt4 book ai didi

google-app-engine - 与另一个 oAuth2 提供商的 Google Cloud Endpoints

转载 作者:太空宇宙 更新时间:2023-11-03 15:18:01 25 4
gpt4 key购买 nike

有没有办法将另一个 OAuth2 提供商与 Google Cloud Endpoints 一起使用?我的意思是,例如,从 Facebook 获取身份验证并像我们使用 Google Account Auth 一样使用它(使用 gapi js 并将用户类放在 @ApiMethod 上)

最佳答案

您必须实现自己的Authenticator 并更新@Api 配置。基于此answer一个简单的身份验证器将如下所示:

public class MyAuthenticator implements Authenticator {

@Override
public User authenticate(HttpServletRequest request) {
String token = request.getHeader("Authorization");
if (token != null) {
// apply your Facebook/Twitter/OAuth2 authentication
String user = authenticate(token);
if (user != null) {
return new User(user);
}
}
return null;
}
}

还有你的 API 定义

@Api(name = "example", authenticators = {MyAuthenticator.class})

有关自定义身份验证器的更多信息,您可以在 Google documentation 中找到.

关于google-app-engine - 与另一个 oAuth2 提供商的 Google Cloud Endpoints,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15872240/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com