diff --git a/src/Components/Caller.php b/src/Components/Caller.php index 6051d4b..c85c7d3 100644 --- a/src/Components/Caller.php +++ b/src/Components/Caller.php @@ -166,30 +166,15 @@ protected function getToken($forceRefresh = false): ?string // Get the auth component $auth = service('firebase')->auth; - // Create a custom token - if (! $custom = $auth->createCustomToken($this->uid)) + // Get a user token + if (! $response = $auth->signInAsUser($this->uid)) { $this->errors[] = 'Unable to generate custom token for user ' . $this->uid; return null; } - // Exchange the custom token for an ID token - if (! $response = $auth->getApiClient()->exchangeCustomTokenForIdAndRefreshToken($custom)) - { - $this->errors[] = 'Failed to exchange token for user ' . $this->uid; - return null; - } - - // Read the token - $body = (string) $response->getBody(); - if (! $data = json_decode($body)) - { - $this->errors[] = 'Unable to decode token response: ' . $body; - return null; - } - // Store the actual ID token - $this->token = $data->idToken; + $this->token = $response->idToken(); return $this->token; } }