3 final class PhabricatorAsanaAuthProvider
4 extends PhabricatorOAuth2AuthProvider
5 implements DoorkeeperRemarkupURIInterface
{
7 public function getProviderName() {
11 protected function getProviderConfigurationHelp() {
12 $app_uri = PhabricatorEnv
::getProductionURI('/');
13 $login_uri = PhabricatorEnv
::getURI($this->getLoginURI());
16 "To configure Asana OAuth, create a new application here:".
18 "https://app.asana.com/-/account_api".
20 "When creating your application, use these settings:".
22 " - **App URL:** Set this to: `%s`\n".
23 " - **Redirect URL:** Set this to: `%s`".
25 "After completing configuration, copy the **Client ID** and ".
26 "**Client Secret** to the fields above.",
31 protected function newOAuthAdapter() {
32 return new PhutilAsanaAuthAdapter();
35 protected function getLoginIcon() {
39 public static function getAsanaProvider() {
40 $providers = self
::getAllEnabledProviders();
42 foreach ($providers as $provider) {
43 if ($provider instanceof PhabricatorAsanaAuthProvider
) {
51 /* -( DoorkeeperRemarkupURIInterface )------------------------------------- */
53 public function getDoorkeeperURIRef(PhutilURI
$uri) {
54 $uri_string = phutil_string_cast($uri);
56 $pattern = '(https://app\\.asana\\.com/0/(\\d+)/(\\d+))';
58 if (!preg_match($pattern, $uri_string, $matches)) {
62 if (strlen($uri->getFragment())) {
66 if ($uri->getQueryParamsAsPairList()) {
70 $context_id = $matches[1];
71 $task_id = $matches[2];
73 return id(new DoorkeeperURIRef())
75 ->setApplicationType(DoorkeeperBridgeAsana
::APPTYPE_ASANA
)
76 ->setApplicationDomain(DoorkeeperBridgeAsana
::APPDOMAIN_ASANA
)
77 ->setObjectType(DoorkeeperBridgeAsana
::OBJTYPE_TASK
)
78 ->setObjectID($task_id);