@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use "rest/api/3/myself" to retrieve JIRA profile details, not "rest/auth/1/session"

Summary:
Ref T13493. At time of writing, the old API method no longer functions: `1/session` does not return an `accountId` but all calls now require one.

Use the modern `3/myself` API instead. The datastructure returned by `2/user` (older appraoch) and `3/myself` (newer approach) is more or less the same, as far as I can tell.

Test Plan: Linked an account against modern-at-time-of-writing Atlassian-hosted JIRA.

Maniphest Tasks: T13493

Differential Revision: https://secure.phabricator.com/D21170

+23 -11
+23 -11
src/applications/auth/adapter/PhutilJIRAAuthAdapter.php
··· 10 10 11 11 private $jiraBaseURI; 12 12 private $adapterDomain; 13 - private $currentSession; 14 13 private $userInfo; 15 14 16 15 public function setJIRABaseURI($jira_base_uri) { ··· 106 105 107 106 private function getUserInfo() { 108 107 if ($this->userInfo === null) { 109 - $this->currentSession = $this->newJIRAFuture('rest/auth/1/session', 'GET') 108 + $this->userInfo = $this->newUserInfo(); 109 + } 110 + 111 + return $this->userInfo; 112 + } 113 + 114 + private function newUserInfo() { 115 + // See T13493. Try a relatively modern (circa early 2020) API call first. 116 + try { 117 + return $this->newJIRAFuture('rest/api/3/myself', 'GET') 110 118 ->resolveJSON(); 119 + } catch (Exception $ex) { 120 + // If we failed the v3 call, assume the server version is too old 121 + // to support this API and fall back to trying the older method. 122 + } 111 123 112 - // The session call gives us the username, but not the user key or other 113 - // information. Make a second call to get additional information. 124 + $session = $this->newJIRAFuture('rest/auth/1/session', 'GET') 125 + ->resolveJSON(); 114 126 115 - $params = array( 116 - 'username' => $this->currentSession['name'], 117 - ); 127 + // The session call gives us the username, but not the user key or other 128 + // information. Make a second call to get additional information. 118 129 119 - $this->userInfo = $this->newJIRAFuture('rest/api/2/user', 'GET', $params) 120 - ->resolveJSON(); 121 - } 130 + $params = array( 131 + 'username' => $session['name'], 132 + ); 122 133 123 - return $this->userInfo; 134 + return $this->newJIRAFuture('rest/api/2/user', 'GET', $params) 135 + ->resolveJSON(); 124 136 } 125 137 126 138 public static function newJIRAKeypair() {