Compare commits

...

2 commits

4 changed files with 63 additions and 3 deletions

View file

@ -1 +1 @@
0.2.0
0.2.1

View file

@ -26,26 +26,56 @@ final class OAuth2AuthorizationRequest {
private readonly int $interval
) {}
/**
* Gets device code, meant to be sent to the server.
*
* @return string
*/
public function getDeviceCode(): string {
return $this->deviceCode;
}
/**
* Gets user code, meant to be entered by the user.
*
* @return string
*/
public function getUserCode(): string {
return $this->userCode;
}
/**
* Gets the verification page URI, without autofill.
*
* @return string
*/
public function getVerificationUri(): string {
return $this->verificationUri;
}
/**
* Gets the verification page URI, with autofill.
*
* @return string
*/
public function getVerificationUriComplete(): string {
return $this->verificationUriComplete;
}
/**
* Gets amount of seconds in which this authorisation requests will expire.
*
* @return int
*/
public function getExpiresIn(): int {
return $this->expiresIn;
}
/**
* Gets amount of seconds at which interval we're meant to poll at.
*
* @return int
*/
public function getInterval(): int {
return $this->interval;
}

View file

@ -24,22 +24,49 @@ final class OAuth2Token {
private readonly string $refreshToken
) {}
/**
* Gets OAuth2 access token.
*
* @return string
*/
public function getAccessToken(): string {
return $this->accessToken;
}
/**
* Gets OAuth2 token type.
*
* Always 'Bearer' unless something crazy happens in the future.
*
* @return string
*/
public function getTokenType(): string {
return $this->tokenType;
}
/**
* Gets amount of seconds in which the access token expires.
*
* @return int
*/
public function getExpiresIn(): int {
return $this->expiresIn;
}
/**
* Gets possible alternate scope than what was initially requested by the application, empty if unchanged.
*
* @return string
*/
public function getScope(): string {
return $this->scope;
}
/**
* Gets refresh token used to request a new access token.
*
* @return string
*/
public function getRefreshToken(): string {
return $this->refreshToken;
}

View file

@ -31,10 +31,13 @@ class V1Client {
*
* @todo Currently there's no format for apps on the server side.
* @throws RuntimeException If there is no authenticated entity.
* @return V1User
* @return ?V1User
*/
public function me(): V1User {
public function me(): ?V1User {
$response = $this->httpClient->request('GET', $this->urls->getApiUrl('/v1/me'));
if($response->getStatusCode() === 401)
return null;
$response->ensureSuccessStatusCode();
$me = $response->getJsonBody();