4 * Authentication adapter for Asana OAuth2.
6 final class PhutilAsanaAuthAdapter
extends PhutilOAuthAuthAdapter
{
8 public function getAdapterType() {
12 public function getAdapterDomain() {
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() {
30 public function getAccountImageURI() {
31 $photo = $this->getOAuthAccountData('photo', array());
32 if (is_array($photo)) {
33 return idx($photo, 'image_128x128');
39 public function getAccountURI() {
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() {
59 public function getExtraAuthenticateParameters() {
61 'response_type' => 'code',
65 public function getExtraTokenParameters() {
67 'grant_type' => 'authorization_code',
71 public function getExtraRefreshParameters() {
73 'grant_type' => 'refresh_token',
77 public function supportsTokenRefresh() {
81 protected function loadOAuthAccountData() {
82 return id(new PhutilAsanaFuture())
83 ->setAccessToken($this->getAccessToken())
84 ->setRawAsanaQuery('users/me')