Created
April 1, 2020 17:26
-
-
Save TheBojda/8fec388254ecc89d78ff9d54002fb81e to your computer and use it in GitHub Desktop.
Firebase Auth - Verify ID token, and get user info in PHP with CURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getUserByToken($token) | |
{ | |
$data = array("idToken" => $token); | |
$data_string = json_encode($data); | |
$ch = curl_init('https://identitytoolkit.googleapis.com/v1/accounts:lookup?key=' . API_KEY); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt( | |
$ch, | |
CURLOPT_HTTPHEADER, | |
array( | |
'Content-Type: application/json', | |
'Content-Length: ' . strlen($data_string) | |
) | |
); | |
$response = json_decode(curl_exec($ch)); | |
return $response->users[0]; | |
} |
hello sorry I'm new to firebase is this code currently functional in firebase?
As I see, it is not functioning from June 30, 2020. :(
(https://developers.google.com/identity/toolkit/migrate-identityplatform)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello sorry I'm new to firebase is this code currently functional in firebase?