From 5ecb77427aec0bbe13e4747a633668d2a2ece323 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 25 Jun 2013 16:31:01 -0700 Subject: [PATCH] Fix OAuth token refresh return value Summary: Ref T1536. Ref T2852. Currently, after refreshing the token we don't actually return it. This means that code relying on token refresh fails once per hour (for Asana) in a sort of subtle way. Derp. Update `bin/auth refresh` to make this failure more clear. Test Plan: Set `force refresh` flag and verified a return value. Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T1536, T2852 Differential Revision: https://secure.phabricator.com/D6295 --- .../PhabricatorAuthManagementRefreshWorkflow.php | 10 ++++++++-- .../auth/provider/PhabricatorAuthProviderOAuth.php | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/applications/auth/management/PhabricatorAuthManagementRefreshWorkflow.php b/src/applications/auth/management/PhabricatorAuthManagementRefreshWorkflow.php index 97957d7c91..b36f28e0dc 100644 --- a/src/applications/auth/management/PhabricatorAuthManagementRefreshWorkflow.php +++ b/src/applications/auth/management/PhabricatorAuthManagementRefreshWorkflow.php @@ -72,7 +72,7 @@ final class PhabricatorAuthManagementRefreshWorkflow $console->writeOut( "%s\n", pht( - "Found %s accounts to refresh.", + "Found %s account(s) to refresh.", new PhutilNumber(count($accounts)))); } @@ -126,7 +126,13 @@ final class PhabricatorAuthManagementRefreshWorkflow new PhutilNumber( $account->getProperty('oauth.token.access.expires') - time()))); - $provider->getOAuthAccessToken($account, $force_refresh = true); + $token = $provider->getOAuthAccessToken($account, $force_refresh = true); + if (!$token) { + $console->writeOut( + "* %s\n", + pht('Unable to refresh token!')); + continue; + } $console->writeOut( "+ %s\n", diff --git a/src/applications/auth/provider/PhabricatorAuthProviderOAuth.php b/src/applications/auth/provider/PhabricatorAuthProviderOAuth.php index 7c9ed7edac..88d1b60369 100644 --- a/src/applications/auth/provider/PhabricatorAuthProviderOAuth.php +++ b/src/applications/auth/provider/PhabricatorAuthProviderOAuth.php @@ -339,6 +339,8 @@ abstract class PhabricatorAuthProviderOAuth extends PhabricatorAuthProvider { $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $account->save(); unset($unguarded); + + return $account->getProperty('oauth.token.access'); } }