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:
parent
4ca38612f2
commit
5ecb77427a
2 changed files with 10 additions and 2 deletions
|
@ -72,7 +72,7 @@ final class PhabricatorAuthManagementRefreshWorkflow
|
||||||
$console->writeOut(
|
$console->writeOut(
|
||||||
"%s\n",
|
"%s\n",
|
||||||
pht(
|
pht(
|
||||||
"Found %s accounts to refresh.",
|
"Found %s account(s) to refresh.",
|
||||||
new PhutilNumber(count($accounts))));
|
new PhutilNumber(count($accounts))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,13 @@ final class PhabricatorAuthManagementRefreshWorkflow
|
||||||
new PhutilNumber(
|
new PhutilNumber(
|
||||||
$account->getProperty('oauth.token.access.expires') - time())));
|
$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(
|
$console->writeOut(
|
||||||
"+ %s\n",
|
"+ %s\n",
|
||||||
|
|
|
@ -339,6 +339,8 @@ abstract class PhabricatorAuthProviderOAuth extends PhabricatorAuthProvider {
|
||||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||||
$account->save();
|
$account->save();
|
||||||
unset($unguarded);
|
unset($unguarded);
|
||||||
|
|
||||||
|
return $account->getProperty('oauth.token.access');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue