Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Firebase自定义令牌无效_Php_Firebase_Token_Firebase Authentication - Fatal编程技术网

Php Firebase自定义令牌无效

Php Firebase自定义令牌无效,php,firebase,token,firebase-authentication,Php,Firebase,Token,Firebase Authentication,我在Firebase上使用自定义令牌身份验证。正如文档所说,我试图生成令牌。但是,当我尝试使用(loginWithCustomToken(token))方法登录客户端时,它会在下面给出一个错误 { "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "INVALID_CUSTOM_TOKEN" } ], "code": 400, "messa

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

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "INVALID_CUSTOM_TOKEN"
   }
  ],
  "code": 400,
  "message": "INVALID_CUSTOM_TOKEN"
 }
}
我使用Firebase文档中描述的代码块生成令牌

$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");
}

我通过更新电脑的时间解决了这个问题。
日期和时间错误,当我更新它时,错误被解决了

您的服务器可能有非UTC的时区。请为您的有效负载提供UTC时间戳。