4
使用Selenium WebDriver,我想處理Facebook身份驗證並使用HtmlUnitDriver獲取Access Token,我該怎麼做?使用Selenium WebDriver的Facebook身份驗證
使用Selenium WebDriver,我想處理Facebook身份驗證並使用HtmlUnitDriver獲取Access Token,我該怎麼做?使用Selenium WebDriver的Facebook身份驗證
了很多這方面的功能,其目的,你必須推斷,但是這是一個測試,我寫了OAuth的流程本身:
$this->loginAsTestUser();
$oauth_uri = $this->fbURI()
->setPath('/dialog/oauth')
->addQueryData('client_id', self::RELL_APP_ID)
->addQueryData('redirect_uri', self::RELL_URL);
$this->open($oauth_uri);
$this->platform->tosApp();
$code = $this->getURI()->getQueryData('code');
$this->assertNotEmpty($code, 'No code returned in redirect url');
$token_uri = $this->fbURI('graph')
->setSecure(true)
->setPath('/oauth/access_token')
->addQueryData('client_id', self::RELL_APP_ID)
->addQueryData('client_secret', self::RELL_SECRET)
->addQueryData('code', $code)
->addQueryData('redirect_uri', self::RELL_URL);
$this->open($token_uri);
$this->assertRegExp(
'/access_token=.+/', $this->source(),
'No access token returned in source');
我相信這可以使用HTTP請求是在REST API級別,繞過Selenium執行UI登錄? – David