public function request_token() { if (empty($this->request->data)) { return $this->render(array('text' => 'Invalid Request', 'status' => 401)); } $consumer = Provider::fetch($this->request->data['oauth_consumer_key']); if (!$consumer) { return $this->render(array('text' => 'Invalid Consumer Key', 'status' => 401)); } $isValid = Provider::verify(array('params' => $this->request->data, 'url' => 'request_token') + (array) $consumer); if ($isValid) { $token = Provider::create('token'); $data = (array) $consumer + (array) $token; Provider::store($consumer->oauth_consumer_key, $data); Provider::store($token->oauth_token, $data); return http_build_query((array) $token); } $this->render(array('text' => 'Invalid Signature', 'status' => 401)); }
public function testVerifyWithToken() { $request = array('url' => 'request', 'params' => array('oauth_consumer_key' => 'key', 'oauth_nonce' => '4d31073c8ce205ecd3145d6cc0a3a4f6', 'oauth_signature' => '10xRa+G7ql3KjDgZySmn5NqNLqQ=', 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_timestamp' => '1259606608', 'oauth_version' => '1.0'), 'token' => array('oauth_token' => 'request_token', 'oauth_token_secret' => 'request_secret')); $result = Provider::verify($request); $this->assertTrue($result); }