1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Tharanga Kothalawala <[email protected]> |
4
|
|
|
* @date 30-12-2018 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace TSK\SSO\ThirdParty\Facebook; |
8
|
|
|
|
9
|
|
|
use TSK\SSO\ThirdParty\VendorConnection; |
10
|
|
|
use TSK\SSO\ThirdParty\VendorConnectionFactory; |
11
|
|
|
use TSK\SSO\Storage\ThirdPartyStorageRepository; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @package TSK\SSO\ThirdParty\Facebook |
15
|
|
|
*/ |
16
|
|
|
class FacebookConnectionFactory implements VendorConnectionFactory |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var ThirdPartyStorageRepository |
20
|
|
|
*/ |
21
|
|
|
private $storageRepository; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
private $defaultGraphVersion; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
private $permissions; |
32
|
|
|
|
33
|
1 |
|
public function __construct( |
34
|
|
|
ThirdPartyStorageRepository $storageRepository, |
35
|
|
|
$defaultGraphVersion = 'v2.12', |
36
|
|
|
$permissions = 'public_profile,email' |
37
|
|
|
) { |
38
|
1 |
|
$this->storageRepository = $storageRepository; |
39
|
1 |
|
$this->defaultGraphVersion = $defaultGraphVersion; |
40
|
1 |
|
$this->permissions = $permissions; |
41
|
1 |
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param string $clientId the client id which can be generated at the third party portal |
45
|
|
|
* @param string $clientSecret this can be found similar to the clientId |
46
|
|
|
* @param string $callbackUrl the url to callback after a third party auth attempt |
47
|
|
|
* @return VendorConnection |
48
|
|
|
*/ |
49
|
1 |
|
public function get($clientId, $clientSecret, $callbackUrl) |
50
|
|
|
{ |
51
|
1 |
|
return new FacebookConnection( |
52
|
1 |
|
new FacebookApiConfiguration( |
53
|
1 |
|
$this->defaultGraphVersion, |
54
|
1 |
|
$clientId, |
|
|
|
|
55
|
1 |
|
$clientSecret, |
56
|
1 |
|
$this->permissions, |
57
|
|
|
$callbackUrl |
58
|
1 |
|
), |
59
|
1 |
|
$this->storageRepository |
60
|
1 |
|
); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|