gpt4 book ai didi

php - Firebase 无效的自定义 token

转载 作者:行者123 更新时间:2023-12-05 05:22:17 29 4
gpt4 key购买 nike

我在 Firebase 上使用自定义 token 身份验证。我尝试按照文档所述生成 token 。但是当我尝试使用 (loginWithCustomToken(token)) 方法登录客户端时,它会在下面给出错误

{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "INVALID_CUSTOM_TOKEN"
}
],
"code": 400,
"message": "INVALID_CUSTOM_TOKEN"
}
}

我按照 Firebase 文档中的描述使用此代码块生成 token

$service_account_email = "USED_FROM_JSON_FILE"; //
$private_key = "USED_FROM_JSON_FILE";

function create_custom_token($uid, $is_premium_account) {
global $service_account_email, $private_key;

$now_seconds = time();
$payload = array(
"iss" => $service_account_email,
"sub" => $service_account_email,
"aud" => "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
"iat" => $now_seconds,
"exp" => $now_seconds+(60*60), // Maximum expiration time is one hour
"uid" => $uid,
"claims" => array(
"premium_account" => $is_premium_account
)
);
return JWT::encode($payload, $private_key, "RS256");
}

最佳答案

我解决了更新 PC 时间的问题。日期时间错误,更新后错误解决

关于php - Firebase 无效的自定义 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40922096/

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