Skip to content

Commit

Permalink
Update Caller for deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Apr 16, 2020
1 parent 2318a27 commit 5860dca
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/Components/Caller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 5860dca

Please sign in to comment.