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 | public function getBaseUri() |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | public function getAuthorizeUri() |
||
37 | |||
38 | /** |
||
39 | * {@inheritdoc} |
||
40 | */ |
||
41 | public function getRequestTokenUri() |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function getName() |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function parseToken($body) |
||
58 | { |
||
59 | $response = json_decode($body, true); |
||
60 | if ($response) { |
||
61 | $token = new AccessToken($response); |
||
62 | |||
63 | // Vimeo return User on get Access Token Request (looks like to protect round trips) |
||
64 | if (isset($response['user'])) { |
||
65 | $hydrator = new ObjectMap(array( |
||
66 | 'name' => 'fullname', |
||
67 | )); |
||
68 | |||
69 | $this->user = $hydrator->hydrate(new User(), (object) $response['user']); |
||
70 | $this->user->id = str_replace('/users/', '', $this->user->uri); |
||
71 | |||
72 | $token->setUid($this->user->id); |
||
73 | } |
||
74 | |||
75 | return $token; |
||
76 | } |
||
77 | |||
78 | throw new InvalidAccessToken('AccessToken is not a valid JSON'); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | public function getIdentity(AccessTokenInterface $accessToken) |
||
88 | } |
||
89 |