1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 17:28:51 +02:00

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
This commit is contained in:
epriestley 2013-06-25 16:31:01 -07:00
parent 4ca38612f2
commit 5ecb77427a
2 changed files with 10 additions and 2 deletions

View file

@ -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",

View file

@ -339,6 +339,8 @@ abstract class PhabricatorAuthProviderOAuth extends PhabricatorAuthProvider {
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$account->save();
unset($unguarded);
return $account->getProperty('oauth.token.access');
}
}