private function retrieveAccessToken(PhabricatorOAuthProvider $provider)
 {
     $request = $this->getRequest();
     $token = $request->getStr('confirm_token');
     if ($token) {
         $this->tokenExpires = $request->getInt('expires');
         $this->accessToken = $token;
         $this->oauthState = $request->getStr('state');
         return null;
     }
     $client_id = $provider->getClientID();
     $client_secret = $provider->getClientSecret();
     $redirect_uri = $provider->getRedirectURI();
     $auth_uri = $provider->getTokenURI();
     $code = $request->getStr('code');
     $query_data = array('client_id' => $client_id, 'client_secret' => $client_secret, 'redirect_uri' => $redirect_uri, 'code' => $code) + $provider->getExtraTokenParameters();
     $future = new HTTPSFuture($auth_uri, $query_data);
     $future->setMethod('POST');
     try {
         list($response) = $future->resolvex();
     } catch (Exception $ex) {
         return $this->buildErrorResponse(new PhabricatorOAuthFailureView());
     }
     $data = $provider->decodeTokenResponse($response);
     $token = idx($data, 'access_token');
     if (!$token) {
         return $this->buildErrorResponse(new PhabricatorOAuthFailureView());
     }
     $this->tokenExpires = $provider->getTokenExpiryFromArray($data);
     $this->accessToken = $token;
     $this->oauthState = $request->getStr('state');
     return null;
 }