有人可以提供一些示例代码来说明如何在Google Cloud端点中验证Firebase令牌吗?最近提出的问题并没有完全澄清(How to integrate firebase authentication with google app engine endpoints)。
在端点中进行Google身份验证是通过向端点添加User参数自动完成的。可以使用Facebook Graph API在云端点中验证Facebook令牌,就像这样:
在端点中进行Google身份验证是通过向端点添加User参数自动完成的。可以使用Facebook Graph API在云端点中验证Facebook令牌,就像这样:
@ApiMethod(name = "endpoint.addUser", httpMethod = HttpMethod.POST)
public ResultObject addUser(HttpServletRequest request, User pUser) throws OAuthRequestException {
String token = request.getHeader("Authorization");
String graphUrl = "https://graph.facebook.com/v2.6/me?fields=id,name,email&access_token=" + token;
URL u = new URL(g);
URLConnection c = u.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream()));
String inputLine;
StringBuffer b = new StringBuffer();
while ((inputLine = in.readLine()) != null){
b.append(inputLine + "\n");
}
in.close();
graph = b.toString();
JSONObject json = new JSONObject(graph);
facebookId = json.getString("id");
email = json.getString("email");
//...
}
验证 Firebase Token 和 Facebook Token 一样简单吗?从 Firebase Token 中获取电子邮件地址是否可行?
com.google.api.server.spi.config.Authenticator
,然后在注解中指定这个Authenticator
。我相信Firebase认证令牌是JWT,所以不需要发送请求来验证它们。 - saiyr