【发布时间】:2018-07-23 11:58:09
【问题描述】:
我正在使用 Firebase-Auth 在我的用 PHP 编码的网络应用上授权用户。授权本身是使用 Javascript 进行的,它在 Ajax-Request 上执行以验证用户是否已登录。
要在服务器上使用 Firebase-Admin,我已经实现了 Firebase-PHP。
现在,在每个 AJX 请求中,我都会获得登录的用户 ID 和 ID 令牌,我想在 PHP 中验证它们,就像在文档中写的 here 一样。
验证本身工作正常。如果令牌存在,我会得到一个“IDToken”-对象。但是我怎样才能再次从该对象中获取用户 ID 以验证该令牌是否适合该用户?
$idTokenString = '...';
try {
$verifiedIdToken = $firebase->getAuth()->verifyIdToken($idTokenString);
// This is the Token-Object where I cant't find the uid-get-Function
} catch (InvalidIdToken $e) {
echo $e->getMessage();
}
我在文档或搜索的类中找不到方法。
【问题讨论】:
标签: php firebase firebase-authentication token