Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / auth / adapter / PhutilAsanaAuthAdapter.php
blob5fe343671e79914799a3ae3d61b5705798e41839
1 <?php
3 /**
4 * Authentication adapter for Asana OAuth2.
5 */
6 final class PhutilAsanaAuthAdapter extends PhutilOAuthAuthAdapter {
8 public function getAdapterType() {
9 return 'asana';
12 public function getAdapterDomain() {
13 return 'asana.com';
16 public function getAccountID() {
17 // See T13453. The Asana API has changed to string IDs and now returns a
18 // "gid" field (previously, it returned an "id" field).
19 return $this->getOAuthAccountData('gid');
22 public function getAccountEmail() {
23 return $this->getOAuthAccountData('email');
26 public function getAccountName() {
27 return null;
30 public function getAccountImageURI() {
31 $photo = $this->getOAuthAccountData('photo', array());
32 if (is_array($photo)) {
33 return idx($photo, 'image_128x128');
34 } else {
35 return null;
39 public function getAccountURI() {
40 return null;
43 public function getAccountRealName() {
44 return $this->getOAuthAccountData('name');
47 protected function getAuthenticateBaseURI() {
48 return 'https://app.asana.com/-/oauth_authorize';
51 protected function getTokenBaseURI() {
52 return 'https://app.asana.com/-/oauth_token';
55 public function getScope() {
56 return null;
59 public function getExtraAuthenticateParameters() {
60 return array(
61 'response_type' => 'code',
65 public function getExtraTokenParameters() {
66 return array(
67 'grant_type' => 'authorization_code',
71 public function getExtraRefreshParameters() {
72 return array(
73 'grant_type' => 'refresh_token',
77 public function supportsTokenRefresh() {
78 return true;
81 protected function loadOAuthAccountData() {
82 return id(new PhutilAsanaFuture())
83 ->setAccessToken($this->getAccessToken())
84 ->setRawAsanaQuery('users/me')
85 ->resolve();