Compare commits
2 commits
6b38e3327e
...
6a93d31375
Author | SHA1 | Date | |
---|---|---|---|
6a93d31375 | |||
d02394f8de |
4 changed files with 63 additions and 3 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
0.2.0
|
0.2.1
|
||||||
|
|
|
@ -26,26 +26,56 @@ final class OAuth2AuthorizationRequest {
|
||||||
private readonly int $interval
|
private readonly int $interval
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets device code, meant to be sent to the server.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getDeviceCode(): string {
|
public function getDeviceCode(): string {
|
||||||
return $this->deviceCode;
|
return $this->deviceCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets user code, meant to be entered by the user.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getUserCode(): string {
|
public function getUserCode(): string {
|
||||||
return $this->userCode;
|
return $this->userCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the verification page URI, without autofill.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getVerificationUri(): string {
|
public function getVerificationUri(): string {
|
||||||
return $this->verificationUri;
|
return $this->verificationUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the verification page URI, with autofill.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getVerificationUriComplete(): string {
|
public function getVerificationUriComplete(): string {
|
||||||
return $this->verificationUriComplete;
|
return $this->verificationUriComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets amount of seconds in which this authorisation requests will expire.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function getExpiresIn(): int {
|
public function getExpiresIn(): int {
|
||||||
return $this->expiresIn;
|
return $this->expiresIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets amount of seconds at which interval we're meant to poll at.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function getInterval(): int {
|
public function getInterval(): int {
|
||||||
return $this->interval;
|
return $this->interval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,22 +24,49 @@ final class OAuth2Token {
|
||||||
private readonly string $refreshToken
|
private readonly string $refreshToken
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets OAuth2 access token.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getAccessToken(): string {
|
public function getAccessToken(): string {
|
||||||
return $this->accessToken;
|
return $this->accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets OAuth2 token type.
|
||||||
|
*
|
||||||
|
* Always 'Bearer' unless something crazy happens in the future.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getTokenType(): string {
|
public function getTokenType(): string {
|
||||||
return $this->tokenType;
|
return $this->tokenType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets amount of seconds in which the access token expires.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
public function getExpiresIn(): int {
|
public function getExpiresIn(): int {
|
||||||
return $this->expiresIn;
|
return $this->expiresIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets possible alternate scope than what was initially requested by the application, empty if unchanged.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getScope(): string {
|
public function getScope(): string {
|
||||||
return $this->scope;
|
return $this->scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets refresh token used to request a new access token.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function getRefreshToken(): string {
|
public function getRefreshToken(): string {
|
||||||
return $this->refreshToken;
|
return $this->refreshToken;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,13 @@ class V1Client {
|
||||||
*
|
*
|
||||||
* @todo Currently there's no format for apps on the server side.
|
* @todo Currently there's no format for apps on the server side.
|
||||||
* @throws RuntimeException If there is no authenticated entity.
|
* @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'));
|
$response = $this->httpClient->request('GET', $this->urls->getApiUrl('/v1/me'));
|
||||||
|
if($response->getStatusCode() === 401)
|
||||||
|
return null;
|
||||||
|
|
||||||
$response->ensureSuccessStatusCode();
|
$response->ensureSuccessStatusCode();
|
||||||
|
|
||||||
$me = $response->getJsonBody();
|
$me = $response->getJsonBody();
|
||||||
|
|
Loading…
Reference in a new issue