1 | <?php |
||
15 | class Vimeo extends \SocialConnect\OAuth2\AbstractProvider |
||
16 | { |
||
17 | /** |
||
18 | * @var User|null |
||
19 | */ |
||
20 | protected $user; |
||
21 | |||
22 | /** |
||
23 | * {@inheritdoc} |
||
24 | */ |
||
25 | 1 | public function getBaseUri() |
|
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | 2 | public function getAuthorizeUri() |
|
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | 2 | public function getRequestTokenUri() |
|
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 3 | public function getName() |
|
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | 3 | public function parseToken($body) |
|
58 | { |
||
59 | 3 | $response = json_decode($body, true); |
|
60 | 3 | if ($response) { |
|
61 | 1 | $token = new AccessToken($response); |
|
62 | |||
63 | // Vimeo return User on get Access Token Request (looks like to protect round trips) |
||
64 | 1 | if (isset($response['user'])) { |
|
65 | $hydrator = new ObjectMap( |
||
66 | [ |
||
67 | 'name' => 'fullname', |
||
68 | ] |
||
69 | ); |
||
70 | |||
71 | $this->user = $hydrator->hydrate(new User(), (object) $response['user']); |
||
72 | $this->user->id = str_replace('/users/', '', $this->user->uri); |
||
73 | |||
74 | $token->setUid($this->user->id); |
||
75 | } |
||
76 | |||
77 | 1 | return $token; |
|
78 | } |
||
79 | |||
80 | 2 | throw new InvalidAccessToken('AccessToken is not a valid JSON'); |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function getIdentity(AccessTokenInterface $accessToken) |
||
90 | } |
||
91 |