Version 5.1 - All the GraphQL #32
@ -138,11 +138,16 @@ final class Auth {
|
|||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function getAuthToken(): ?string
|
public function getAuthToken(): ?string
|
||||||
|
{
|
||||||
|
if (PHP_SAPI === 'cli')
|
||||||
{
|
{
|
||||||
return $this->segment->get('auth_token', NULL)
|
return $this->segment->get('auth_token', NULL)
|
||||||
?? $this->cache->get(K::AUTH_TOKEN_CACHE_KEY, NULL);
|
?? $this->cache->get(K::AUTH_TOKEN_CACHE_KEY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->segment->get('auth_token', NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the refresh token
|
* Retrieve the refresh token
|
||||||
*
|
*
|
||||||
@ -150,11 +155,16 @@ final class Auth {
|
|||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function getRefreshToken(): ?string
|
private function getRefreshToken(): ?string
|
||||||
|
{
|
||||||
|
if (PHP_SAPI === 'cli')
|
||||||
{
|
{
|
||||||
return $this->segment->get('refresh_token')
|
return $this->segment->get('refresh_token')
|
||||||
?? $this->cache->get(K::AUTH_TOKEN_REFRESH_CACHE_KEY, NULL);
|
?? $this->cache->get(K::AUTH_TOKEN_REFRESH_CACHE_KEY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->segment->get('refresh_token');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the new authentication information
|
* Save the new authentication information
|
||||||
*
|
*
|
||||||
|
@ -155,19 +155,26 @@ final class Model {
|
|||||||
*/
|
*/
|
||||||
public function reAuthenticate(string $token)
|
public function reAuthenticate(string $token)
|
||||||
{
|
{
|
||||||
$response = $this->getResponse('POST', K::AUTH_URL, [
|
$response = $this->requestBuilder->getResponse('POST', K::AUTH_URL, [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
|
'accept' => NULL,
|
||||||
|
'Content-type' => 'application/x-www-form-urlencoded',
|
||||||
'Accept-encoding' => '*'
|
'Accept-encoding' => '*'
|
||||||
|
|
||||||
],
|
],
|
||||||
'form_params' => [
|
'form_params' => [
|
||||||
'grant_type' => 'refresh_token',
|
'grant_type' => 'refresh_token',
|
||||||
'refresh_token' => $token
|
'refresh_token' => $token
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$data = Json::decode(wait($response->getBody()->buffer()));
|
$data = Json::decode(wait($response->getBody()->buffer()));
|
||||||
|
|
||||||
|
if (array_key_exists('error', $data))
|
||||||
|
{
|
||||||
|
dump($data['error']);
|
||||||
|
dump($response);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
if (array_key_exists('access_token', $data))
|
if (array_key_exists('access_token', $data))
|
||||||
{
|
{
|
||||||
return $data;
|
return $data;
|
||||||
|
Loading…
Reference in New Issue
Block a user