PHP 홈 페이지 을 사용하여 사용자 정의 토큰 생성 아래에 https://firebase.google.com/docs/auth/admin/create-custom-tokens이라는 PHP 사용자 지정 토큰에 권장되는 패키지를 설치했습니다.Firebase 커스텀 토큰 PHP 서버 생성 오류
php-jwt을 설치했습니다. 그런 다음 here이라는 서비스 계정을 만들고 /apis/credentials에서 다운로드 한 것과 비슷한 세부 정보를 얻습니다.
"private_key": "-----BEGIN PRIVATE KEY-----veryLongKey---END PRIVATE KEY-----\n",
"client_email": "[email protected]",
그런 다음 맨 위에있는 링크로 표시된 형식을 사용하여 토큰을 생성합니다.
그러나 나는
$url = 'https://localhost-42d67.firebaseio.com/Devices.json?auth=' .$theCreatedToken;
$arr = array("success" =>array("iPhone"=>500));
$data_string = json_encode($arr);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
echo $result = curl_exec($ch);
내가이 오류
{ "오류"를 얻을 ....이 컬의 $theCreatedToken
것을 넣을 때 ".의 ID 토큰을 예상하지만 사용자 정의 토큰을 받았다" }
내가 ?auth=' .$theCreatedToken;
을 제거하면 작동합니다. 내가 뭘 잘못하고 있니? 나는 이것을 광범위하게 조사했지만 대답은 없다. 누군가 도와 주길 바랍니다. 최고
나는이 해결책을 따랐지만 똑같은 오류를 일으켰다. [link] (http://stackoverflow.com/questions/37801444/setting-up-firebase-v3-custom-auth-with-php) – Sprep
$ theCreatedToken은 어떻게 얻었습니까? –
$ theCreatedToken이 JWT 라이브러리에서 반환됩니다. – Sprep