/** * Exchange a request token for an access token. * The exchange is only succesful iff the request token has been authorized. * * Never returns, calls exit() when token is exchanged or when error is returned. */ public function accessToken() { try { $this->verifyRequest(self::TOKEN_TYPE_REQUEST); $options = array(); $ttl = $this->request->get('xoauth_token_ttl'); if ($ttl) { $options['token_ttl'] = $ttl; } $verifier = $this->request->get('oauth_verifier'); if ($verifier) { $options['verifier'] = $verifier; } $store = $this->store; $token = $store->exchangeConsumerRequestForAccessToken($this->request->getParam('oauth_token', true), $options); /** @var /Foundation/Oauth/Secrets $token */ $content = array("oauth_token" => $token->token, "oauth_token_secret" => $token->token_secret); if ($token->ttl) { $content['xoauth_token_ttl'] = $token->ttl; } $this->response->setContent(http_build_query($content)); $this->response->setStatusCode(200, ""); $this->response->setContentType("application/x-www-form-urlencoded"); } catch (OauthException $e) { $this->response->setStatusCode(401, "OAuth Verification Failed: " . $e->getMessage()); } return $this->response; }