forked from webfox/laravel-xero-oauth2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOauthCredentialManager.php
100 lines (83 loc) · 2.41 KB
/
OauthCredentialManager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace Webfox\Xero;
use League\OAuth2\Client\Token\AccessTokenInterface;
interface OauthCredentialManager {
/**
* Get the current access token
*/
public function getAccessToken(): string;
/**
* Get the current refresh token
*/
public function getRefreshToken(): string;
/**
* Get the url to redirect the user to authenticate
*/
public function getAuthorizationUrl(): string;
/**
* Get all tenants available
**/
public function getTenants(): ?array;
/**
* Get the current tenant ID
*/
public function getTenantId(int $tenant =0): string;
/**
* Get the time the current access token expires (unix timestamp)
*/
public function getExpires(): int;
/**
* Get the current 'state' used to verify callbacks
*/
public function getState(): string;
/**
* Check whether we have any credentials stored
*/
public function exists(): bool;
/**
* Check whether the current access token is expired
*/
public function isExpired(): bool;
/**
* Refresh and store the new token
*/
public function refresh(): void;
/**
* Store the details of the access token
*
* Should store array [
* 'token' => $token->getToken(),
* 'refresh_token' => $token->getRefreshToken(),
* 'id_token' => $token->getValues()['id_token'],
* 'expires' => $token->getExpires(),
* 'tenants' => $tenants ?? $this->getTenants(),
* ]
*
* @param AccessTokenInterface $token
* @param Array|null $tenants
*/
public function store(AccessTokenInterface $token, array $tenants = null): void;
/**
* Get the current authenticated users details according to the id token
* @return array [
* 'given_name' => 'string',
* 'family_name' => 'string',
* 'email' => 'string',
* 'user_id' => 'string',
* 'username' => 'string',
* 'session_id' => 'string',
* ]
*/
public function getUser(): ?array;
/**
* Get the current data stored via the store method.
* @return array [
* 'token' => 'string',
* 'refresh_token' => 'string',
* 'id_token' => 'string',
* 'expires' => 000000,
* 'tenants' => 'array',
* ]
*/
public function getData(): array;
}